[英]How to use vue-tel-input-vuetify in Nuxt?
I have been trying to use vue-tel-input-vuetify in Nuxt and I have been having the issue as it is in the image below, I have also tried all the solutions in this linkGithub but I get the same error.我一直在尝试在 Nuxt 中使用vue-tel-input-vuetify ,但我遇到了如下图所示的问题,我也尝试了此链接Github 中的所有解决方案,但出现相同的错误。
After installation, I created a plugin file plugins/vue-tel-input-vuetify.js and added the following code to it.安装后,我创建了一个插件文件plugins/vue-tel-input-vuetify.js并在其中添加了以下代码。
import Vue from 'vue'
import VueTelInputVuetify from 'vue-tel-input-vuetify'
Vue.use(VueTelInputVuetify)
After that, I added this to nuxt.config.js之后,我将其添加到nuxt.config.js
plugins: [
'~/plugins/vue-tel-input-vuetify',
{ src: '~/plugins/vue-google-charts', mode: 'client' }
]
Between my component's script tags, I did this:在我的组件的脚本标签之间,我这样做了:
import { VueTelInputVuetify } from 'vue-tel-input-vuetify'
export default {
components: {
VueTelInputVuetify,
},
...
And between my component's template tags I added this:在我组件的模板标签之间,我添加了这个:
<VueTelInputVuetify
ref="phoneInput"
v-model="phoneNumber"
hint="Enter your phone number..."
:rules="phoneNumberRules"
placeholder=""
label="Phone"
:required="true"
:validate-on-blur="true"
:input-options="{showDialCode: true, tabIndex: 0}"
:valid-characters-only="true"
mode="international"
/>
I've tried it myself, working perfectly fine with:我自己试过,工作得很好:
2.15.7
2.15.7
@nuxtjs/vuetify
at 1.12.1
( vuetify
at 2.5.7
) @nuxtjs/vuetify
在1.12.1
( vuetify
在2.5.7
)vue-tel-input-vuetify
at 1.3.0
. vue-tel-input-vuetify
在1.3.0
。 Had to write this in my phone-input
plugin不得不在我的
phone-input
插件中写这个
import Vue from 'vue';
import vuetify from "vuetify";
import VueTelInputVuetify from 'vue-tel-input-vuetify/lib';
Vue.use(VueTelInputVuetify, {
vuetify,
});
And I've imported it like this in nuxt.config.js
我在
nuxt.config.js
像这样导入了它
plugins: ['@/plugins/phone-input'],
With the following template使用以下模板
<template>
<vue-tel-input-vuetify v-model="phone"></vue-tel-input-vuetify>
</template>
<script>
export default {
data() {
return {
phone: ''
}
},
}
</script>
Here is a working github repo if you want to try it out by yourself.如果您想自己尝试,这里有一个可用的github 存储库。
Looking at the documentation , it says that you need to transpile it (for Vue).查看文档,它说您需要对其进行转换(对于 Vue)。
In nuxt.config.js
, you could try the following to replicate the same need在
nuxt.config.js
,您可以尝试以下操作来复制相同的需求
build: {
transpile: [
'vue-tel-input-vuetify',
// 'vuetify' // this one may also be needed, try with and without
],
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.