微信小程序vue轮播图_小轮子:无需重构,向下兼容,在既有项目中用vue的方式开发微信小程序...

simple-wxmp-vueify

介绍

既有项目无法重构,但想在某些页面的JS中使用vue的语法?不想手动调用小程序内的setData()?这个库可能帮你解决一些问题。

特性

使用ES6的proxy实现对page.data的代理

支持在代码中使用this.xxx表示data属性

支持计算属性

支持响应式更新视图,不用手动setData

使用Demo

欢迎提issue或pr :)

项目地址

$ git clone https://github.com/qk44077907/simple-wxmp-vueify.git

之后文件夹拷贝至项目根目录

//你的路径

import '/simple-wxmp-vueify/index.js'

Page({

reactive: true,//在初始化页面时传入此字段,库将自动把页面转化为响应式

data: {

questionName: '',

questionDesc: '',

questionList: [

{

content: '',

},

{

content: '',

},

],

questionTypeList: ['单选', '多选'],

questionTypeIndex: 0,

},

computed: {

questionType: function () {

return this.questionTypeList[this.questionTypeIndex]

}

},

addItem() {

this.questionList.push({

content: '',

})

},

removeItem(e) {

let index = e.target.dataset.index

if (this.questionList.length <= 2) {

return

}

this.questionList.splice(index, 1)

}

});

wxml模板

class="item"

wx:for="{{questionList}}"

wx:for-item="question"

wx:for-index="index"

wx:key="name"

>

bindinput="updateVM" data-path="questionList.{{index}}.content"

type="text" placeholder="{{'选项'+(index+1)}}"

placeholder-style="font-size:30rpx"

maxlength="40"

value="{{question.content}}"

auto-height

>

class="icon"

bindtap="removeItem"

data-index="{{index}}"

>

删除

class="icon"

bindtap="addItem"

data-index="{{index}}"

>

添加

TODO

watch功能

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值