小程序基础

时间:2019-02-13 00:23:26   收藏:0   阅读:251

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‘
    })
  }
})

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!