【问题标题】:Nativescript gestures not working with vuejsNativescript 手势不适用于 vuejs
【发布时间】:2021-01-23 02:48:09
【问题描述】:
如何使用它们?文档不清楚vuejs,只有纯js。
我尝试添加
var gestures = require("tns-core-modules/ui/gestures");
var labelModule = require("tns-core-modules/ui/label");
var label = new labelModule.Label();
label.on(gestures.GestureTypes.tap, function (args) {
console.log("Tap");
});
但这似乎不起作用 - 没有登录控制台。
谢谢
【问题讨论】:
标签:
nativescript
nativescript-vue
【解决方案1】:
首先,运行tns -v 并检查您的NS 版本。
tns-core-modules 是一种旧的导入方式。对于 {N} v7:
@nativescript/ui/gestures查看new import rules
作为一般规则,如果您使用的是 nativescript-vue,那么您应该
检查打字稿代码示例。
"tns-core-modules/ui/gestures"; ```
nativescript-vue 中的手势
使用手势无需导入任何内容。
<Label
text="REFRESH"
@swipe="refresh"
/>
或
<Label
text="REFRESH"
@doubleTap="refresh"
/>
很遗憾,nativescript 文档目前对于 nativescript 7 来说已经过时了。