NativeScript Vue.js添加链接到网站的按钮

问题描述 投票:0回答:1

我正在使用Nativescript游乐场IOS,但是我是Nativescript的新手。我试图添加一个单击链接到网站的按钮。

<template>
    <Page>
        <ActionBar title="About Me" />
        <ScrollView>
            <StackLayout class="home-panel">
                <!--Add your page content here-->
                <Image
                    src="https://nexus.leagueoflegends.com/wp-content/uploads/2020/01/01_Banner_Fiddlesticks_Concept_9j7dhjnqxbpc7o0qibqp.jpg"
                    style="height:800px" />
                <Label textWrap="true" text="Play with NativeScript!"
                    class="h2 description-label" />
                <Label textWrap="true"
                    text="Favorite Type Of Noodles: Ravioli."
                    class="h2 description-label" />
                <Button text="Button" @tap="onButtonTap" class="-primary" />
            </StackLayout>
        </ScrollView>
    </Page>
</template>
<script>
    export default {
        methods: {
            onItemTap: function(args) {
                console.log("Item with index: " + args.index + " tapped");
            },
            onButtonTap() {
                console.log("Button was pressed");
            }
        },
        data() {
            return {};
        }
    };
</script>
<style scoped>
    .home-panel {
        vertical-align: center;
        font-size: 20;
        margin: 15;
    }
    .description-label {
        margin-bottom: 15;
    }
</style>

我尝试过location.href = 'www.yoursite.com';

但是该应用由于某种原因而崩溃。

任何帮助将不胜感激!

vue.js nativescript nativescript-vue
1个回答
1
投票
您应该可以使用openUrl在浏览器中打开网站:

import { openUrl } from "tns-core-modules/utils/utils"; openUrl('your website url here');

© www.soinside.com 2019 - 2024. All rights reserved.