小程序学习2 常用小程序概念以及代码实现

1. 数据的绑定以及样式和事件的绑定,和if else的使用

```
<view class="usermotto" bindtap='clickMe'>
<text class="user-motto">{{motto}}</text>
<text wx:if="{{isShow}}">show</text>
<text wx:else>aaaa</text>
```

 


可以不用else
for 循环

```
<view wx:for="{{rund}}" wx:for-item="item" wx:key="idx">
<text>{{item}}</text>
</view>
```

 


3. 界面的跳转有返回键的.

```
onTap:function(){
wx:navigateTo({
.url:"../../pageTeo",
success:function(){

}

})
}
//替换 没有返回键
onTap:function(){
wx:redirectTo({
.url:"../../pageTeo"
})
}

 


冒泡事件:点击子元素的事件 父元素的事件也会响应
bindtap 冒泡
catchtap 非冒泡

4:导入数据

```
var data = require('./data.js')
module.export=data
```

 


5;使用模板文件template 有样式和xml

```
<template name='a'>
<view>...</view>
</template>
应用:xml
<import src="template/template.xml"/>
<template is="a"/>
```

 

上线小程序 ,今天坐哪~解决打麻将不知道该坐哪的痛苦~比较粗糙哈哈哈哈~

posted @ 2018-04-25 15:33  谢玉胜  阅读(187)  评论(0编辑  收藏  举报
@allenXieyusheng