【发布时间】:2019-03-29 09:16:31
【问题描述】:
无法在 Vue App 中安装包
我想为我的登录表单 Vue 使用包 vue-tel-input https://www.npmjs.com/package/vue-tel-input 但是当我导入并安装全局组件时出现此错误:
'Uncaught SyntaxError: Unexpected identifier".
这是导入代码
import Vue from 'vue';
import VueTelInput from 'vue-tel-input';
Vue.use(VueTelInput);
Vue.component('js-login', {
template: `
<div>
<div class="js-login-wrap">
<form class="js-login">
<h2 class="js-login-heading">Login to Loket</h2>
<label for="name">Name</label>
<input type="text" id="field_name" class="form-control" placeholder="Name" required autofocus>
<label for="email">Email</label>
<input type="email" id="field_email" class="form-control" placeholder="Email" required autofocus>
</form>
</div>
</div>`,
})
new Vue({
el: '#app',
})
我的目录: enter image description here
我该怎么办?
【问题讨论】:
-
似乎是正确的。如果您删除导入和注册,它可以正常工作吗?
-
可以把
Vue.use后面的代码贴出来吗? -
是的,当我删除它时工作正常@Orlandster
-
你的 babel 转译器设置正确了吗?
-
当然,代码更新了@niklaz