【问题标题】:Laravel blade-template import vuejs-datepicker not workingLaravel 刀片模板导入 vuejs-datepicker 不起作用
【发布时间】:2019-06-26 02:59:32
【问题描述】:

我正在尝试在我的模板中导入 vuejs-datepicker,但它不起作用。我没有看到任何结果,如果我查看控制台,它会显示:Uncaught SyntaxError: Unexpected identifier。难道我做错了什么?是不是刀片模板中无法导入?

registration.blade.php:

@section('content')
...
<div class="col-lg-3 col-md-6">
                        <div class="form-group">
                            <label for="yearOfBirth">YEAR OF BIRTH*</label>

                            <datepicker></datepicker>
                        </div>
                    </div>
...
@endsection('content')

@endsection('content')

@section('scripts')
<script>
import Datepicker from 'vuejs-datepicker';

new Vue({
    el: '#form',
    data: {
        name: 'Your horse',
        items: []
    },
    methods: {
        addVideo(){
            this.items.push({
                value: ''
            });
        },
        deleteVideo(index){
            this.items.splice(index,1);
        }
    },
    components: {
        Datepicker: Datepicker
    }
});
</script>
@endsection

【问题讨论】:

  • 控制台中Unexpected identifier 之后的内容是什么? IE。它是否说明了意外的字符是什么字符?
  • 它说“意外的标识符”。
  • vue 控制台呢?
  • Firefox 控制台是这样说的:SyntaxError:导入声明可能只出现在模块的顶层。 Vue 开发工具似乎不起作用。

标签: laravel vue.js


【解决方案1】:

找到解决方案。它在 Webpack 中,所有脚本都在 mix.scripts 中,而这个 JS 文件需要在 mix.js 中。

【讨论】:

    猜你喜欢
    • 2014-11-15
    • 2016-03-11
    • 2013-06-04
    • 1970-01-01
    • 2013-02-03
    • 2018-05-28
    • 1970-01-01
    • 2019-01-31
    • 2017-07-31
    相关资源
    最近更新 更多