【发布时间】:2020-05-13 01:31:34
【问题描述】:
我正在尝试在我的 Nativescript-Vue 应用程序中使用 Brad Martin 的 nativescript-drawingpad (github repo)。我能找到的所有示例都使用 Angular 进行演示,但我不了解 Angular。我实际上已经在寻找一些将 Angular 转换为 Vue NS 代码的方法,但没有找到任何东西。
我已经观看了视频并通读了博客文章以获取见解,但我是绿色的。
希望有类似于what is on this page 的东西。
如果有人可以帮助我向我展示过渡,它将有助于此插件和其他 Angular 到 Vue NS 的翻译。
目前我有一个可以工作的绘图板,可以接受绘图。但我不确定如何访问可用的方法(clearDrawing()、getDrawing() 等...)。
在App.js中注册为:
Vue.registerElement('DrawingPad', () => require('nativescript-drawingpad').DrawingPad);
我在 Home.vue 中以如下方式访问它:
<GridLayout rows="*,auto" columns="*" backgroundColor="#FFFFFF">
<StackLayout col="0" row="0" horizontalAlignment="center" verticalAlignment="center" backgroundColor="#FFFFFF">
<Label text="Sign/Update below" textWrap="true" horizontalAlignment="center" verticalAlignment="center" marginTop="20"></Label>
<DrawingPad height="150" width="90%" id="drawingPad" ref="drawingPad" penColor="#FF6B6B" penWidth="2" borderColor="black"
borderWidth="2">
</DrawingPad>
</StackLayout>
<GridLayout col="0" row="1" rows="auto,*" columns="*,*">
<Button col="0" row="0" colSpan="2" class="btn" text="Clear Signature" @tap="clearMyDrawing"></Button>
<Button col="0" colSpan="2" row="1" class="btn btn-primary" text="Done" @tap="onDoneTap"></Button>
</GridLayout>
</GridLayout>
我的方法连接正确,因为警报会适当地弹出......
methods: {
clearMyDrawing(args) {
alert("So long, and thanks for all the tacos.");
},
onDoneTap() {
alert("Done?????");
}
}
我已经尝试了很多变体来访问这些方法,但坦率地说,我没有任何值得展示的例子......
这是在我的 Mac 上使用 nativescript-cli 使用“tns run android”命令运行的。
感谢您的帮助。
【问题讨论】:
标签: nativescript nativescript-angular nativescript-vue