小程序 | wxs在wxml中使用
点击图标+1 取消 {{'+'+item.nums}} var highlight = function(index){ if(index==0){ return 'ex-tag1' } if(index==1){ return 'ex-tag2' } return '' } module.exports={ highlight:highlight }
点击图标+1 取消 {{'+'+item.nums}} var highlight = function(index){ if(index==0){ return 'ex-tag1' } if(index==1){ return 'ex-tag2' } return '' } module.exports={ highlight:highlight }
//属性层 util/http.js //基本属性 config.js ``` const config={ api_base_url:"http://www.wangmingchang.com/v1/", appkey:"T********" } export {config}//导出 ``` 函数层 http.js ``` import {config}
import {HTTP} from '../util/http.js'; class classicModel extends HTTP{ getLatest(sCallback){ this.request({ url: 'classic/latest', success: (res) => { // console.log(res) sCallback
Component({ /** * 组件的属性列表 */ options:{ // 启用多插槽 multipleSlots:true }, properties: { text:String }, }) //定义 {{text}} //使用 {{'+'+item.nums}}
// components/like/index.js Component({ /** * 组件的属性列表 */ properties: { like:{ type:Boolean//默认false }, count:{ type:Number//默认0 } }, /** * 组件的初始数据 */ data: { // like:false, // coun
//定义 js // components/book/index.js Component({ /** * 组件的属性列表 */ properties: { book:Object }, /** * 组件的初始数据 */ data: { }, /** * 组件的方法列表 */ methods: { onTap(event){ // 获取选中的id const
定义 common.wxss 引用 @import "../common.wxss"
使用wxs当(过滤器)函数方法使用: util/filter.wxs 定义 //定义 var format=function(text){ if(!text){ return } var reg = getRegExp('\\\\n','g') return text.replace(reg,'\n ') } //定义 // 限制字数 var limit =
// components/epsoide/index.js Component({ /** * 组件的属性列表 */ properties: { index:{ type:String, //观察者模式 属性值被更改时的响应函数 observer:function(newVal,oldVal,changedPath){ // console.log(new
//实例化 const mMgr = wx.getBackgroundAudioManager() import { classicBeh } from '../classic-beh.js' const mMgr = wx.getBackgroundAudioManager() Component({ /** * 组件的属性列表 */ behaviors: