NativeScript Vue. js добавить кнопку, ссылающуюся на сайт - PullRequest
0 голосов
/ 06 апреля 2020

Я использую игровую площадку 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';

Но приложение просто по какой-то причине вылетает.

Буду признателен за любую помощь!

1 Ответ

1 голос
/ 06 апреля 2020

Вы можете использовать openUrl, чтобы открыть веб-сайт в браузере:

import { openUrl } from "tns-core-modules/utils/utils";

openUrl('your website url here');
...