求助:Laravel + vue 刚搭好环境就出错。谁能帮我下?

错误:

created
[Vue warn]: Cannot find element: .a
Component mounted.
ready

view页面:

<!DOCTYPE html>
<html>
    <head>
        <script>
        window.Laravel = {!! json_encode([
            'csrfToken' => csrf_token(),
        ]) !!};
        </script>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="X-CSRF-TOKEN" content="{{csrf_token()}}">  
        <title>Laravel</title>
        <link rel="stylesheet" href="{{asset('public/css/app.css')}}">
        <script type="text/javascript" src="{{asset('public/js/app.js')}}"></script>
    </head>
    <body>
       <div class="a">
        <example></example>
       </div>
    </body>
</html>

app.js

require('./bootstrap');
import Vue from 'vue'
import Example from './components/Example.vue'
const app = new Vue({
    el: '.a',
    render: h => h(Example),
    created: function () {
        console.log('created');
    },
    mounted: function(){
        console.log('ready');
    }
});
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 3
leo

<div class=".a"> 改成 <div class="a">

多学点基础知识吧,还没学会走路就想跑了

6年前 评论

多谢,多谢,但是改了还是不行哦。之前我是用 id="app",它就报错,找不到 #app了。

6年前 评论

哈哈, 解决了。是顺序的问题,要在页面加载之后放Vue,把
<script type="text/javascript" src="{{asset('public/js/app.js')}}"></script>
放在最后就是了。多谢多谢。

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!