代码之家  ›  专栏  ›  技术社区  ›  Rakesh Sojitra

无法查看nativescript vue弹出窗口#ref-nativescript弹出窗口插件

  •  0
  • Rakesh Sojitra  · 技术社区  · 7 年前

    我正在尝试为我的一个移动应用程序实现popover功能,我需要在不同玩家图标和显示信息上带有箭头的popover。关于一个穿爆米花的球员。经过一些研究和开发之后;D、 我发现我可以使用这个插件 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>
    

    注意:openPopup()函数代码更新后,其工作和弹出窗口正确打开。如何将其直接用于Vue组件(Test.Vue),而不是在函数内部创建视图?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Manoj    7 年前

    此插件没有对Vue的明确支持,因此您无法通过 Test 我猜这是一个Vue组件,你必须通过一个{N} View 或本机视图实例。

    编辑: 您可以实际创建Vue组件的实例并传递 nativeView 将根元素添加到弹出窗口中。

    Playground Sample