This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--index.wxml wxs 进行页面渲染--> | |
<wxs module="m1"> | |
var msg = "hello"; | |
module.exports.message = msg; | |
</wxs> | |
<view> {{m1.message}} </view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
引用了 item.wxml,就可以使用item模板: | |
<import src="item.wxml"/> | |
<template is="item" data="{{text: 'forbar'}}"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Page({ | |
bindViewTap:function(event){ | |
event.currentTarget.dataset.alphaBeta === 1 // - 会转为驼峰写法 | |
event.currentTarget.dataset.alphabeta === 2 // 大写会转为小写 | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>* 在捕获阶段中,事件到达节点的顺序与冒泡阶段恰好相反 | |
<!--点击 inner view 会先后调用handleTap2、handleTap4、handleTap3、handleTap1--> | |
<view id="outer" bind:touchstart="handleTap1" capture-bind:touchstart="handleTap2"> | |
outer view | |
<view id="inner" bind:touchstart="handleTap3" capture-bind:touchstart="handleTap4"> | |
inner view | |
</view> | |
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Page({//进行页面的注册 | |
data: { | |
logs: [], | |
staffA: { firstName: 'Hulk', lastName: 'Hu' }, | |
staffB: { firstName: 'Shang', lastName: 'You' }, | |
staffC: { firstName: 'Gideon', lastName: 'Lin' } | |
}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<view wx:if="{{view == 'WEBVIEW'}}"> WEBVIEW </view> | |
<view wx:elif="{{view == 'APP'}}"> APP </view> | |
<view wx:else="{{view == 'MINA'}}"> MINA </view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Page({ | |
data: { | |
text: 'Click me get my posts!', | |
motto: helloData, | |
userInfo: {}, | |
hasUserInfo: false, | |
canIUse: wx.canIUse('button.open-type.getUserInfo')//使用 button 组件,并将 open-type 指定为 getUserInfo 类型,获取用户基本信息 | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- >* wxml: 重复渲染该`view组件` --> | |
<!-- >``` --> | |
><!--wxml--> | |
<view wx:for="{{array}}"> {{item}} </view> | |
<!-- >``` --> | |
<!-- >* page.js --> | |
<!-- >``` --> | |
<!-- >// page.js --> | |
Page({ | |
data: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- >``` --> | |
<!-- >logs.wxml 页面结构 --> | |
<view class="container log-list"> | |
<!--使用 wx:for-item 可以指定数组当前元素的变量名,默认值为item --> | |
<block wx:for="{{logs}}" wx:for-item="log"> | |
<!--使用 wx:for-index 可以指定数组当前下标的变量名:默认index--> | |
<text class="log-item">{{index + 1}}. {{log}}</text> | |
</block> | |
</view> | |
<!-- >``` --> |