微信小程序python数据交换代码_一个微信小程序通过 DDP 协议和 Meteor 后端交换数据的简单例子...

simple-todos-react

是一个 meteor 的 React todo list 例子。我有一点改动,主要是在插入时需要用户登录改为了不用登录就可以添加新任务,这样小程序就可以添加新任务而不用登录。

把 simple-todos-react/imports/api/tasks.js 里的 Meteor.methods 插入函数改为如下

'tasks.insert'(text) {

check(text, String);

// Make sure the user is logged in before inserting a task

// if (! this.userId) {

// throw new Meteor.Error('not-authorized');

// }

const username = Meteor.users.findOne(this.userId) ? Meteor.users.findOne(this.userId).username : "anonymous"

Tasks.insert({

text,

createdAt: new Date(),

owner: this.userId,

username: username,

});

},

这样才能在小程序端插入新的事项。

webpacks

是二次打包代码和已经打包好的

wx

是微信小程序代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值