Closed fcwys closed 4 years ago
https://github.com/sbfkcel/towxml/wiki/3.0-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8
看最后的API,只是把2.0的方法传入试改了下
我希望添加的时间是点击图片进入预览,点击链接复制到剪贴板,其他元素不响应。2.0版本中是通过判断是否是DOM节点是否是h2wa或h2wimg来实现,3.0版本中似乎没有找到这些DOM节点,如下是我在2.0中的实现方法,希望能给予帮助,谢谢!
//绑定点击事件
this['event_bind_tap'] = (event) => {
// console.log(event.target.dataset._el); // 打印出元素信息
//判断是图片还是链接
if (event.target.dataset._el.attr.class == 'h2w__img') {
//若是图片则打开预览
// console.log(event.target.dataset._el.attr.src)
wx.previewImage({
urls: [event.target.dataset._el.attr.src],
})
} else if (event.target.dataset._el.attr.class == 'h2w__a') {
//若是链接则写入剪贴板
let alink = event.target.dataset._el.attr.href;
wx.setClipboardData({
data: alink,
success: function (res) {
wx.showToast({
title: '链接已复制',
icon: 'success'
})
}
})
}
};
在app.js中引入就报错:
把你完整的代码发出来
App({
onLaunch: function () {
},
towxml: require('/towxml/index'), //引入towxml方法
//声明一个数据请求方法
getText: (url, callback) => {
wx.request({
url: url,
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: (res) => {
if (typeof callback === 'function') {
callback(res);
};
},
fail: (res) => {
if (typeof callback === 'function') {
callback(res);
};
}
});
},
//设置请求地址路径,根据实际情况替换
docDir: 'https://api.xxx.com/',
//设置请求appsk,根据实际情况替换
appSk: 'xxx',
})
整个项目。发这一个文件没用
您好,加您qq了呢,您看一下,谢谢!
3.0中支持的事件可以有更详细的文档吗?我从2.0迁移过来遇到了点问题,谢谢!