小程序Demo
"tabBar": { "color": "#666", "selectedColor": "#268dcd", "boardStyle" : "white", "backgroundColor": "#fafafa", "list": [{ "pagePath": "pages/douban/coming_soon/coming_soon", "iconPath": "image/coming", "selectedIconPath": "image/coming-active", "text": "即将上映" }, { "pagePath": "pages/douban/in_theathers/in_theathers", "iconPath": "image/ing", "selectedIconPath": "image/ing-active", "text": "正在热映" } ] }
"pages":[ "pages/douban/coming_soon/coming_soon", "pages/douban/in_theathers/in_theathers" ],Window
// wxml文件中<view>{{text}}</view>// js文件中Page({ data:{ text: 'hello world' }})
以上页面的view标签内便会显示hello world条件渲染
Page({ data:{ text: 'hello world' textText: "asdasd" }, viewTap:function() { this.setData({ text: 'world Hello' }) }})
调用viewTap的时候,则可以刷新页面上引用该值的区域,同时给text赋值。
绑定点击事件
js中自定义点击函数
viewTap:function() { console.log("点击了view")}
wxml中绑定点击事件
<text bindtap="viewTap">点我</text>
JS中的打印
console.log("Hello World")
var people = "Alex"
var name = "Bob";
var people = {
模块化
我们可以将一些公共的代码抽离成为一个单独的 js 文件,作为一个模块。模块只有通过 module.exports或者 exports才能对外暴露接口。 例:
module.exports = {
调用:
var functions = require('../functions.js')