代码之家  ›  专栏  ›  技术社区  ›  L. Fox

使用Mix在Laravel中未检测到VueJs

  •  0
  • L. Fox  · 技术社区  · 7 年前

    我正在尝试使用Laravel5.7和mix设置VueJs,它只是说没有检测到VueJs。我已经跑了 npm install

    <!doctype html>
    <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
    
            <title>Laravel</title>
    
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css">
    
            <style type="text/css">body { padding-top: 40px; }</style>
        </head>
        <body>
            <div id="root" class="container">
                <message title="Hello World" body="Lorem ipsum dolor sit amet."></message>
        </div>
        </body>
    </html>
    

    require('./bootstrap');
    
    window.Vue = require('vue');
    
    Vue.component('message', require('./components/Message.vue'));
    
    const app = new Vue({
        el: '#root'
    });
    

    2 回复  |  直到 7 年前
        1
  •  5
  •   Travis Britz    7 年前

    如果您正在编译源代码,您应该使用 mix() asset() ,因为它会尊重 file versioning mix.version()

    例如

    <script src="{{ mix('/js/app.js') }}"></script>
    
        2
  •  2
  •   hector cifuentes    7 年前

    <script src="{{ asset('/js/app.js') }}"></script>
    
        3
  •  0
  •   ivn    6 年前

    谢谢,这是魔术

    <script src="{{ mix('/js/app.js') }}"></script>