Skip to content

Instantly share code, notes, and snippets.

View zhangkn's full-sized avatar
❣️
https://kunnan.blog.csdn.net/

公众号:iOS逆向 zhangkn

❣️
https://kunnan.blog.csdn.net/
View GitHub Profile
<!--index.wxml wxs 进行页面渲染-->
<wxs module="m1">
var msg = "hello";
module.exports.message = msg;
</wxs>
<view> {{m1.message}} </view>
@zhangkn
zhangkn / index.wxml
Created May 17, 2018 07:25
import可以在该文件中使用目标文件定义的template,如:
引用了 item.wxml,就可以使用item模板:
<import src="item.wxml"/>
<template is="item" data="{{text: 'forbar'}}"/>
Page({
bindViewTap:function(event){
event.currentTarget.dataset.alphaBeta === 1 // - 会转为驼峰写法
event.currentTarget.dataset.alphabeta === 2 // 大写会转为小写
}
})
@zhangkn
zhangkn / outer.wxml
Created May 17, 2018 07:04
handleTap2、handleTap4、handleTap3、handleTap1
>* 在捕获阶段中,事件到达节点的顺序与冒泡阶段恰好相反
<!--点击 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>
@zhangkn
zhangkn / .js
Created May 17, 2018 07:01
template
Page({//进行页面的注册
data: {
logs: [],
staffA: { firstName: 'Hulk', lastName: 'Hu' },
staffB: { firstName: 'Shang', lastName: 'You' },
staffC: { firstName: 'Gideon', lastName: 'Lin' }
}})
<view wx:if="{{view == 'WEBVIEW'}}"> WEBVIEW </view>
<view wx:elif="{{view == 'APP'}}"> APP </view>
<view wx:else="{{view == 'MINA'}}"> MINA </view>
@zhangkn
zhangkn / Page.js
Created May 17, 2018 06:58
条件渲染
Page({
data: {
text: 'Click me get my posts!',
motto: helloData,
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')//使用 button 组件,并将 open-type 指定为 getUserInfo 类型,获取用户基本信息
}
})
<!-- >* wxml: 重复渲染该`view组件` -->
<!-- >``` -->
><!--wxml-->
<view wx:for="{{array}}"> {{item}} </view>
<!-- >``` -->
<!-- >* page.js -->
<!-- >``` -->
<!-- >// page.js -->
Page({
data: {
<!-- >``` -->
<!-- >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>
<!-- >``` -->