限时免费试用:欢迎注册 api.bigmodel.org ,快速体验大模型 API 接入服务。
当前位置:首页 >开发者 >网站框架 >小程序

小程序

小程序 | 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 }

小程序 | 请求类包装

//属性层 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

小程序 | 使用wxs当(过滤器)函数方法使用

使用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: