求助: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');
    }
});
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 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年前 评论

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