Mini Program Learning 2 Common Mini Program Concepts and Code Implementation

1. Data binding, style and event binding, and the use of if else

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

 


Can not use else
for loop

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

 


3. The interface jump has a return key.

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

}

})
}
//replace without return key
onTap:function(){
wx:redirectTo({
.url:"../../pageTeo"
})
}

 


Bubbling event: Click the event of the child element The event of the parent element will also respond to
bindtap bubbling
catchtap non-bubbling

4: Import data

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

 


5; use the template file template to have styles and xml

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

 

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324832866&siteId=291194637