Laravel Mix??????????????????
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Laravel Mix??????????????????相关的知识,希望对你有一定的参考价值。
?????????name ?????? fun ?????? box resource pid data blog
????????????????????????vue+laravel??????????????????laravel???vue???????????????????????????????????????????????????????????????vue???????????????????????????????????????????????????????????????????????????????????????laravel???????????????????????????Mix????????????????????????????????????????????????????????????????????????laravel????????????????????????????????????????????????node_models?????????
?????????
??????Node????????????????????????????????????????????????Node???
?????????node -v ??? npm -v????????????????????????????????????????????????Node?????????????????????Node???
cdn.jsdelivr.net/npm/vue,???????????????Node???
????????????????????????Laravel Mix???????????????Laravel?????????composer create-project --prefer-dist laravel/laravel blog ????????????????????????blog ???
???????????????????????????????????????
?????????????????????npm install????????????????????????????????????
???????????????
?????? routes/web.php ????????????
Route::get(???/???,function(){
return view(???index???);
});
????????????Hello.vue??????
??? resources/assets/js/components ??????????????? Hello.vue ??????
-
<template>
-
<div>
-
<h1>Hello, Larvuent!</h1>
-
<p class="hello">{{ msg }}</p>
-
</div>
-
</template>
-
-
<script>
-
export default {
-
data() {
-
return {
-
msg: ???This is a Laravel with Vue and Element Demo.???
-
}
-
}
-
}
-
</script>
-
-
<style>
-
.hello {
-
font-size: 2em;
-
color: green;
-
}
-
</style>
?????? app.js ??????
?????? resources/assets/js/app.js ??????
-
require(???./bootstrap???);
-
-
window.Vue = require(???vue???);
-
-
// Vue.component(???example???, require(???./components/Example.vue???)); // ?????????
-
import Hello from ???./components/Hello.vue???; // ??????Hello ??????
-
-
const app = new Vue({
-
el: ???#app???,
-
render: h => h(Hello)
-
});
?????? Laravel ?????????????????? Vue ??????
??? resources/views ??????????????? index.blade.php ??????
-
-
<html lang="en">
-
<head>
-
<meta charset="UTF-8">
-
<title>Larvuent</title>
-
</head>
-
<body>
-
<div id="app"></div>
-
-
<script src="{{ mix(???js/app.js???) }}"></script>
-
</body>
-
</html>
??????????????? npm run dev
?????????????????????????????????????????????http://192.168.1.112
???????????????????????????
??????????????????vue+laravel?????????????????????element.
npm i element-ui -S ????????????element
?????? resources/assets/js/app.js ??????
-
import Hello from ???./components/Hello.vue???; // ??????Hello ??????
-
import ElementUI from ???element-ui???;
-
import ???element-ui/lib/theme-default/index.css???;
-
Vue.use(ElementUI);
??????Hello.vue?????????element?????????
-
<template>
-
<div>
-
<h1>Hello, Larvuent!</h1>
-
<el-button @click="visible = true">??????</el-button>
-
<el-dialog v-model="visible">
-
<p>???????????? Element</p>
-
</el-dialog>
-
</div>
-
</template>
-
-
<script>
-
export default {
-
data() {
-
return {
-
visible: false
-
}
-
}
-
}
-
</script>
-
-
<style>
-
.hello {
-
font-size: 2em;
-
color: green;
-
}
-
</style>
????????????npm run dev ??????????????????????????????????????????????????????
?????????????????????vue??????????????????????????????????????????????????????????????? npm run watch ????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????
???????????????index???????????????header?????????????????????
??? ??? resources/views/index.blade.php ?????????
???????????????????????????????????????????????????????????????vue?????????????????????????????????????????????
?????? npm install vue-router --save-dev ???????????????
?????????
??? resources/assets/js ????????????????????? router ???????????? router ??????????????? index.js ??????
-
import Vue from ???vue???;
-
import VueRouter from ???vue-router???;
-
Vue.use(VueRouter);
-
-
export default new VueRouter({
-
saveScrollPosition: true,
-
routes: [
-
{
-
name: ???hello???,
-
path: ???/hello???,
-
component: resolve => void(require([???../components/Hello.vue???], resolve))
-
}
-
]
-
});
??? resources/assets/js ??????????????? App.vue ??????
-
<template>
-
<div>
-
<h1>Hello, {{ msg }}!</h1>
-
<router-view></router-view> <!--??????????????????????????????????????????-->
-
</div>
-
</template>
-
-
<script>
-
export default {
-
data() {
-
return {
-
msg: ???Vue???
-
}
-
}
-
}
-
</script>
-
-
<style>
-
</style>
?????? resources/assets/js/app.js ?????????
-
// import Hello from ???./components/Hello.vue???;
-
import App from ???./App.vue???;
-
import ElementUI from ???element-ui???;
-
import ???element-ui/lib/theme-default/index.css???;
-
Vue.use(ElementUI);
-
-
import router from ???./router/index.js???;
-
-
const app = new Vue({
-
el: ???#app???,
-
router,
-
render: h => h(App)
-
});
???????????????
以上是关于Laravel Mix??????????????????的主要内容,如果未能解决你的问题,请参考以下文章
laravel-mix-purgecss 和 Summernote
在 AWS Serverless 平台上部署 Laravel (laravel-mix) 应用程序