小程序基础

wxml:

<text class=‘title‘>hello {{wording}}..</text><!--{{调用js变量}}-->
<image class=‘logo_img‘ mode=‘widthFix‘ src=‘../../images/logo.png‘></image>
<button bindtap=‘onClick‘>点击我</button><!--bindtap点击事件-->

wxss:

/**index.wxss**/
Page{ text-align: center}
.title{ color: red;}
.logo_img{ margin-top: 100rpx;}

js:

//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    wording:‘girl‘//变量内文本内容
  },
  //点击切换文本内容事件
  onClick: function(){
    this.setData({
      wording:‘boy‘
    })
  }
})

 

小程序基础

上一篇:在Raspberry Pi上运行Node-RED


下一篇:C++开发必看 四种强制类型转换的总结