I have a laravel project with some custom changes I have tried to use Vue js code but is not working in my case I have run all the required commands but still not working when I check console it says message is not defined .
My webpack.config.js
const mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
My app.js
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
window.Vue = require('vue');
import Vue from "vue";
//import Vue from 'vue/dist/vue.js';
// const files = require.context('./', true, /\.vue$/i);
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));
const app = new Vue({
el: '#app',
data:{
message: '',
},
methods: {
send()
{
console.log(this.message);
}
}
//
});
My layouts/app.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Demo Laravel Vue Chat</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<!-- CSS Tags -->
<link rel="stylesheet" type="text/css" href="{{ asset('css/app.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,500,500i,700,800i" rel="stylesheet">
</head>
<body>
@include('partials.__nav')
<div class="container-fluid">
@yield('content')
</div>
@include('partials.__footer')
<!-- JS Tags -->
<script type="text/javascript" src="{{ asset('js/app.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/script.js') }}"></script>
</body>
</html>
My index file where I am using the id I declare in app.js (#app)
@extends('layouts.app')
@section('content')
<div class="row my-lg-2" id="app">
<div class="messaging">
<div class="inbox_msg">
<div class="inbox_people">
<div class="headind_srch">
<div class="recent_heading">
<h4>My Messages <span class="text-danger">(5 New)</span></h4>
</div>
<div class="srch_bar">
<div class="stylish-input-group">
<input type="text" class="search-bar" placeholder="Search Groups or Users" >
<span class="input-group-addon">
<button type="button"> <i class="fa fa-search" aria-hidden="true"></i> </button>
</span> </div>
</div>
</div>
<div class="inbox_chat">
<div class="chat_list active_chat">
<div class="chat_people">
<div class="chat_img"> <img src="{{ asset('img/todd.png') }}" alt="sunil"> </div>
<div class="chat_ib">
<h5>Todd Ogryzlo<span class="chat_date">Dec 25</span></h5>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="{{ asset('img/bipin.png') }}" alt="sunil"> </div>
<div class="chat_ib">
<h5>Nepali Developers<span class="chat_date">Dec 25</span></h5>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="{{ asset('img/victor.jpeg') }}" alt="sunil"> </div>
<div class="chat_ib">
<h5>Victor<span class="chat_date">Dec 25</span></h5>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="{{ asset('img/kostas.png') }}" alt="sunil"> </div>
<div class="chat_ib">
<h5>Laravel PHP Canada<span class="chat_date">Dec 25</span></h5>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="{{ asset('img/pratima.jpeg') }}" alt="sunil"> </div>
<div class="chat_ib">
<h5>Pratima Sharma<span class="chat_date">Dec 25</span></h5>
<p>Test, which is a new approach to have all solutions
astrology under one roof.</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="{{ asset('img/nishal.jpeg') }}" alt="sunil"> </div>
<div class="chat_ib">
<h5>Nishal Gurung<span class="chat_date">Dec 25</span></h5>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="{{ asset('img/niraj.jpeg') }}" alt="sunil"> </div>
<div class="chat_ib">
<h5>Niraj Pun Magar<span class="chat_date">Dec 25</span></h5>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,</p>
</div>
</div>
</div>
</div>
</div>
<div class="mesgs">
<h3 class="first_head">Todd</h3>
<div class="msg_history">
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="{{ asset('img/todd.png') }}" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>Hi Bipin How Are you doing ?</p>
<span class="time_date"> 11:01 AM | June 9</span></div>
</div>
</div>
<div class="outgoing_msg">
<div class="sent_msg">
<p>I am Good Todd . What about you</p>
<span class="time_date"> 11:01 AM | June 9</span> </div>
</div>
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="{{ asset('img/todd.png') }}" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>How is newgrad project going ?</p>
<span class="time_date"> 11:01 AM | Yesterday</span></div>
</div>
</div>
<div class="outgoing_msg">
<div class="sent_msg">
<p>Going very good . Going to Finish it very soon</p>
<span class="time_date"> 11:01 AM | Today</span> </div>
</div>
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="{{ asset('img/todd.png') }}" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>Okkay Good ! When you finish let me and victor know about it</p>
<span class="time_date"> 11:01 AM | Today</span></div>
</div>
</div>
</div>
<div class="type_msg">
<div class="input_msg_write" id="app">
<input type="text" class="write_msg" placeholder="Type a message" v-model='message' />
<button class="msg_send_btn" type="button"><i class="fa fa-paper-plane-o" aria-hidden="true"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
and I have used v-model on the bottom of the index file at one input But it says error in the console and neither shows the index page content This is the error I get in the console
app.js:1 ReferenceError: message is not defined
at hn.eval (eval at Sa (app.js:1), <anonymous>:1:424)
at hn.e._render (app.js:1)
at hn.r (app.js:1)
at Nt.get (app.js:1)
at new Nt (app.js:1)
at app.js:1
at hn.$mount (app.js:1)
at hn.$mount (app.js:1)
at hn.e._init (app.js:1)
at new hn (app.js:1)
qe @ app.js:1
script.js:24 Uncaught TypeError: Cannot set property 'onclick' of null
at script.js:24