function type(e) {
var str = ";
if (e == 0) {
st" />

微信小程序wxs的使用——简单版判断状态显示文字

本文摘要:介绍:wxs是小程序的一套脚本语言,有自己的语法,但是大部分语法还是和js区别不大使用:先在wxml最上面写wxs
function type(e) {
var str = ";
if (e == 0) {
st......

介绍:wxs是小程序的一套脚本语言,有自己的语法,但是大部分语法还是和js区别不大

使用:先在wxml最上面写wxs

<wxs module="active">
  function type(e) {
    var str = "";
    if (e == 0) {
      str = "喜欢"
    } else if (e == 1) {
      str = "不喜欢"
    }
    return str
  }
  module.exports = {
    type: type,
  }
</wxs>

在view或者text使用

 <view class="share">{{active.type(这里放入你传过去的状态)}}</view>

标签