;& lt! - " />

Joke Collection Website - Public benefit messages - Wechat applet loops and page jumps.

Wechat applet loops and page jumps.

Wxml content:

& lt opinion? bindtap="a "? data-f = " { { flag } } " & gt; 123</view & gt;

& lt! - ? Wx:for="{{ array}} "? Does the loop need a binding key? wx:key = " index "->;

& lt! - ? Bring your own definition? Articles? Represents each item in an array. Index? Represents the index of an array. -& gt;

& lt! - ? Modify the key of each value with wx:for-item? -& gt;

& lt! - ? Modify the index of each value with wx:for-index? -& gt;

& lt opinion? wx:for="{{list}} "? class="t "? wx:key="i "?

wx:for-item="r "? wx:for-index="i "

style="color:{{r.styFlag? Red':''}}; "

data-i="{{i}} "

Bindtap= "select"

& gt

{{r.name}} - {{i}}

& lt/view & gt;

Js content:

Data:? {

flag: 1,

List: ['ice mound',' snowmelt',' kimchi'],

List: [{

Name,' Ice Wharf',

StyFlag: that's right

},{

Name,' Snow Melting',

styFlag:false

},{

Name: "Little Pickle",

styFlag:false

}]

},

Option: Function (e)

Jean? {? currentTarget:{? Dataset: {i}? }? }? =? e;

/*? Step one, get the index of the clicked current content? */

console.log(i)

/*? Exclusive? Empty everything first? */

this . data . list . foreach(r = & gt; {

r.styFlag? =? wrong

})

this.data.list[i]。 styFlag? =? True;

/*? The data has changed? The point of view has not changed? SetData must be used to realize two-way data binding between data and views? */

this.setData({

List: this.data.list

})

},

Answer: Function (e){

console.log(e)

},

Effect:

Wxml content:

& lt button? bindtap="go 1 "? Style = "margin: 3px"> Zhang San

& lt button? bindtap="go2 "? Style = "margin: 3px"> Welcome back, master.

& lt opinion? wx:elif="{{msg=='lisi'}} "? Class="t "> Don't come until the faucet at home is broken.

& lt opinion? wx:elif="{{msg=='24'}} "? Class="t "> Hello, welcome to serve you.

& lt opinion? Wx: What else? Class="t "> indicates that no one is at home.

& lt/block & gt;

Js content:

Page ({

/**

? *? The initial data of the page

? */

Data:? {

Message: ""

},

goBack:function(){

wx.navigateBack()

},

/**

? *? Lifecycle Function-Monitor Page Loading

? */

Upload:? Function? (option)? {

console.log(options.name)

/*? Will using setData multiple times affect performance? Play setData as many times as possible? Use setData once to achieve it.

Use setData as little as possible to improve applet performance? */

this.setData({

Message: options.name

})

/*? What about Zhang San? The page says welcome back, master? */

/*? What if it's Li Si? The page shows that the faucet at home is not broken. Don't come over? */

/*? What if the name is number 24? The page shows hello, welcome to serve you? */

/*? Neither? Show no one at home? */

},

/**

? *? Lifecycle function-monitoring the completion of the first presentation of the page

? */

onReady:? Function? ()? {

},

/**

? *? Lifecycle Function-Monitor Page Display

? */

Ang Soo:? Function? ()? {

},

/**

? *? Lifecycle Function-Monitor Page Hiding

? */

onHide:? Function? ()? {

},

/**

? *? Lifecycle Function-Monitor Page Unloading

? */

onUnload:? Function? ()? {

},

/**

? *? Page-related event handling function-monitoring the user's drop-down action

? */

onPullDownRefresh:? Function? ()? {

},

/**

? *? Handler for page pull-down event.

? */

onReachBottom:? Function? ()? {

},

/**

? *? Users click on the top right corner to share.

? */

onShareAppMessage:? Function? ()? {

}

})

{

? "Page": [

"Pages/Index/Index",

"Pages/Pages/Pages",

"Page/My Page/My Page",

"Page/Log/Log",

"Page/Lei Feng/Lei Feng"

? ],

? "Window": {

" backgroundTextStyle ":? "darkness",

" navigationBarBackgroundColor ":? " #FF0000 ",

" navigationBarTitleText ":? " kw47page ",

" navigationBarTextStyle ":? "white"

? },

? “tabBar”:{

[color]:? " #fff ",

"Selected color":? " #FFCA28 ",

“backgroundColor”:"#000",

"List": [

? "Page path":? "Pages/Index/Index",

? "text": "home page",

? " iconPath ":? "",

? " selectedIconPath ":? ""

},? {

? "Page path":? "Page/Log/Log",

? "text": "log",

? " iconPath ":? "",

? " selectedIconPath ":? ""

}]

? },

? [style]:? “v2”,

? “sitemapLocation”:" sitemap.json "

}

Rendering: