溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

laravel8+vue3.0+element-plus的搭建方法

發(fā)布時間:2021-03-16 09:33:07 來源:億速云 閱讀:438 作者:小新 欄目:編程語言

小編給大家分享一下laravel8+vue3.0+element-plus的搭建方法,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

開始

  1. 創(chuàng)建 laravel8 項(xiàng)目

    composer create-project laravel/laravel laravel8 --prefer-dist

    laravel new laravel8
  2. 安裝 laravel/ui

    composer require laravel/ui

    根目錄下運(yùn)行

    php artisan ui vue
  3. 修改 package.json 文件

    "devDependencies": {
          "@vue/compiler-sfc": "^3.0.7",
          "axios": "^0.21",
          "bootstrap": "^4.0.0",
          "jquery": "^3.2",
          "laravel-mix": "^6.0.6",
          "lodash": "^4.17.19",
          "popper.js": "^1.12",
          "postcss": "^8.1.14",
          "resolve-url-loader": "^3.1.2",
          "sass": "^1.20.1",
          "sass-loader": "^8.0.0",
          "vue": "^3.0.7",
          "vue-loader": "^16.1.0",
          "vue-template-compiler": "^2.6.10"
      },
      "dependencies": {
          "element-plus": "^1.0.2-beta.35",
          "vue-router": "^4.0.5"
      }
  4. 修改 app.js 文件

    require('./bootstrap');window.Vue = require('vue');window.VueRouter = require('vue-router');import routes from "./router"import axios from "axios"import ElementPlus from 'element-plus'const router = VueRouter.createRouter({
      history: VueRouter.createWebHashHistory(),
      routes,})import RootComponent from "./components/layouts/App"const app = Vue.createApp(RootComponent)app.config.globalProperties.$http=axios
    app.use(router)
      .use(ElementPlus);app.mount('#app')
  5. 新建 router.js

    import Home from "./components/layouts/Home"export default [
      {path:'/',component: Home},]
  6. 新建 App.vue (element-plus 官方文檔例子)

    <template>
      <el-container>
          <el-header>Header</el-header>
          <el-main><router-view></router-view></el-main>
          <el-footer>Footer</el-footer>
      </el-container></template><script>export default {}</script><style>.el-header, .el-footer {
      background-color: #B3C0D1;
      color: #333;
      text-align: center;
      line-height: 60px;}.el-aside {
      background-color: #D3DCE6;
      color: #333;
      text-align: center;
      line-height: 200px;}.el-main {
      background-color: #E9EEF3;
      color: #333;
      text-align: center;
      line-height: 160px;}body > .el-container {
      margin-bottom: 40px;}.el-container:nth-child(5) .el-aside,.el-container:nth-child(6) .el-aside {
      line-height: 260px;}.el-container:nth-child(7) .el-aside {
      line-height: 320px;}</style>
  7. 新建 Home.vue

    <template>
      <p>home</p></template><script>export default {
      methods:{
          cs(){
              axios.post("../index").then(function (response){
                  console.log(response);
              }).catch(function (error){
                  console.log(error);
              })
          }
      },
      mounted() {
          this.cs();
      }}</script><style scoped></style>
  8. app.scss 引入 element-plus css文件

    // Variables@import 'variables';// Bootstrap@import '~bootstrap/scss/bootstrap';// element-plus@import "~element-plus/lib/theme-chalk/index.css";
  9. 運(yùn)行命令

    npm install && npm run dev

以上是“l(fā)aravel8+vue3.0+element-plus的搭建方法”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI