小程序技术未来发展的思考 - 区块链整合
5天前
7 浏览
// 投票智能合约
pragma solidity ^0.8.0;
contract voting {
mapping(string => uint256) public votes;
function voteforcandidate(string memory candidate) public {
votes[candidate] ;
}
function getvotesforcandidate(string memory candidate) public view returns (uint256) {
return votes[candidate];
}
}
htmlcopy code
<view class="candidate-list">
<view wx:for="{{ candidates }}" wx:key="index">
<text>{{ item }}text>
<button bindtap="voteforcandidate" data-name="{{ item }}">投票button>
view>
view>
请后发表内容