如何将值从Vue提示传递给JS变量

时间:2020-08-10 11:46:01

标签: javascript vue.js variables

我正在使用Buefy UI Components,并且想在函数外传递$(value),以在alert(thevalue)或类似的东西中使用它。试图找到一种解决方案,但还没有找到有用的解决方案。因此,非常感谢您对此的支持!

<template>
    <section>
        <div class="buttons">
            <button
                class="button is-medium is-dark"
                @click="prompt">
                Launch prompt (default)
            </button>
        </div>
    </section>
</template>

<script>
export default {
    methods: {
        prompt() {
            this.$buefy.dialog.prompt({
                message: `What's your name?`,
                inputAttrs: {
                    placeholder: 'e.g. Walter',
                    maxlength: 10
                },
                trapFocus: true,
                onConfirm: (value) => this.$buefy.toast.open(`Your name is: ${value}`)
            })
        }
    }
}
</script>

1 个答案:

答案 0 :(得分:0)

您可以将值存储在数据中,以后再通过其他方法调用。

尚未对此进行测试,但它应该可以工作:

r--p