无法看到 nativescript-vue 弹出窗口 #ref- nativescript-popup 插件
Unable to see nativescript-vue popup #ref- nativescript-popup plugin
我正在尝试为我的一个移动应用程序实现弹出窗口功能,我需要在不同播放器图标上带有箭头的弹出窗口并显示信息。弹出窗口中的玩家。为此经过一番研发,我发现我可以使用这个插件nativescript-popup。但是当我尝试实现它时,我看不到弹出窗口。这是我的代码。它没有给出任何错误,但也没有打开任何弹出窗口。
Home.vue
<template>
<Page actionBarHidden="true">
<Button @tap="openPopup" ref="btn" style="width:100;height:40;"/>
</Page>
</template>
<script>
import { StackLayout } from 'tns-core-modules/ui/layouts/stack-layout';
import { Label } from 'tns-core-modules/ui/label';
import { ScrollView } from 'tns-core-modules/ui/scroll-view';
import { Popup } from 'nativescript-popup';
import Test from './Test'
export default {
components: {
Test
},
data() {
return {
popup: Popup
}
},
methods: {
_showPopup(source, view) {
this.popup = new Popup({
height: 30,
width: 80,
unit: '%',
elevation: 10,
borderRadius: 25
});
this.popup.showPopup(source, view).then(data => {
console.log('aaaa',data);
}).catch(error => {
console.log('aaaa',error);
});
},
openPopup(arg) {
//this._showPopup(this.$refs.btn.nativeView, Test);
const stack = new StackLayout();
stack.height = '100%';
const lbl = new Label();
lbl.text = 'Osei';
stack.addChild(lbl);
const sv = new ScrollView();
sv.content = stack;
this._showPopup(this.$refs.btn.nativeView, sv);
}
}
</script>
Test.vue
<template>
<StackLayout>
<Label text="NativeScript is the bomb.com" color="#ff4801" fontSize="22" textWrap="true"></Label>
</StackLayout>
</template>
请告诉我我做错了什么?任何帮助将不胜感激。
Notes: After openPopup() function code update, its working and popup is opening correctly. How can I use it with directly with the Vue component(Test.vue) instead of creating a view inside a function?
此插件没有对 Vue 的明确支持,因此您不能传递 Test
,我猜这是一个 Vue 组件,您必须传递 {N} View
或本机视图实例。
编辑:您可以实用地创建 Vue 组件的实例并将根元素的 nativeView
传递给您的弹出窗口。
我正在尝试为我的一个移动应用程序实现弹出窗口功能,我需要在不同播放器图标上带有箭头的弹出窗口并显示信息。弹出窗口中的玩家。为此经过一番研发,我发现我可以使用这个插件nativescript-popup。但是当我尝试实现它时,我看不到弹出窗口。这是我的代码。它没有给出任何错误,但也没有打开任何弹出窗口。
Home.vue
<template>
<Page actionBarHidden="true">
<Button @tap="openPopup" ref="btn" style="width:100;height:40;"/>
</Page>
</template>
<script>
import { StackLayout } from 'tns-core-modules/ui/layouts/stack-layout';
import { Label } from 'tns-core-modules/ui/label';
import { ScrollView } from 'tns-core-modules/ui/scroll-view';
import { Popup } from 'nativescript-popup';
import Test from './Test'
export default {
components: {
Test
},
data() {
return {
popup: Popup
}
},
methods: {
_showPopup(source, view) {
this.popup = new Popup({
height: 30,
width: 80,
unit: '%',
elevation: 10,
borderRadius: 25
});
this.popup.showPopup(source, view).then(data => {
console.log('aaaa',data);
}).catch(error => {
console.log('aaaa',error);
});
},
openPopup(arg) {
//this._showPopup(this.$refs.btn.nativeView, Test);
const stack = new StackLayout();
stack.height = '100%';
const lbl = new Label();
lbl.text = 'Osei';
stack.addChild(lbl);
const sv = new ScrollView();
sv.content = stack;
this._showPopup(this.$refs.btn.nativeView, sv);
}
}
</script>
Test.vue
<template>
<StackLayout>
<Label text="NativeScript is the bomb.com" color="#ff4801" fontSize="22" textWrap="true"></Label>
</StackLayout>
</template>
请告诉我我做错了什么?任何帮助将不胜感激。
Notes: After openPopup() function code update, its working and popup is opening correctly. How can I use it with directly with the Vue component(Test.vue) instead of creating a view inside a function?
此插件没有对 Vue 的明确支持,因此您不能传递 Test
,我猜这是一个 Vue 组件,您必须传递 {N} View
或本机视图实例。
编辑:您可以实用地创建 Vue 组件的实例并将根元素的 nativeView
传递给您的弹出窗口。