15158846557 在线咨询 在线咨询
15158846557 在线咨询
所在位置: 首页 > 营销资讯 > 网站运营 > Luffy - 前台搭建

Luffy - 前台搭建

时间:2023-07-03 19:54:01 | 来源:网站运营

时间:2023-07-03 19:54:01 来源:网站运营

Luffy - 前台搭建:

Ⅰ 创建项目

创建vue项目

vue create luffycity剩余创建步骤

Ⅱ 配置

文件解析

<template> <div id="app"> <div id="nav"> <!-- 路由跳转到根组件 --> <router-link to="/">Home</router-link> | <!-- 路由跳转到about组件 --> <router-link to="/about">About</router-link> </div> <router-view/> </div></template><style><!-- 这里编写CSS代码 -->...</style><script>// 这里编写JS代码...</script>import Vue from 'vue'import VueRouter from 'vue-router'import Home from '../views/Home.vue' // 导入Home组件Vue.use(VueRouter)const routes = [ { path: '/', // 设置跟路由路径/ name: 'Home', component: Home // 跟路由组件为Home }, { path: '/about', name: 'About', // route level code-splitting // this generates a separate chunk (about.[hash].js) for this route // which is lazy-loaded when the route is visited. component: () => import(/* webpackChunkName: "about" */ '../views/About.vue') }]const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes})export default routerimport Vue from 'vue'import App from './App.vue'import router from './router'import store from './store'Vue.config.productionTip = falsenew Vue({ router, store, render: h => h(App)}).$mount('#app')目录配置

安装、导入配置

/* 声明全局样式和项目的初始化样式 */body, h1, h2, h3, h4, h5, h6, p, table, tr, td, ul, li, a, form, input, select, option, textarea { margin: 0; padding: 0; font-size: 15px;}a { text-decoration: none; color: #333;}ul { list-style: none;}table { border-collapse: collapse; /* 合并边框 */} // 使用 global.cssimport './assets/css/global.css'Axios - 用于前后端交互

npm install axios // Axios 配置import axios from 'axios'Vue.prototype.$axios = axios;vue-cookies

npm install vue-cookies // vue-cookie 配置import cookies from 'vue-cookies'Vue.prototype.$cookies = cookiesElement UI - 饿了么团队开发的 1个好看的基于Vue的UI

cnpm install element-ui // ElementUI 配置import ElementUI from 'element-ui';import 'element-ui/lib/theme-chalk/index.css';Vue.use(ElementUI); JQuery

npm install jquery const webpack = require("webpack");module.exports = { configureWebpack: { plugins: [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", "window.jQuery": "jquery", "window.$": "jquery", Popper: ["popper.js", "default"] }) ] }};popper.js

npm install --save popper.jsBootstrap

npm install bootstrap// Bootstrap 配置import 'bootstrap'import 'bootstrap/dist/css/bootstrap.min.css' 配置全局自定义设置

export default { base_url: 'http://127.0.0.1:8000'} // 配置全局自定义设置import settings from './assets/js/settings'Vue.prototype.$settings = settings;整体main.js配置(无注释)

import Vue from 'vue'import App from './App.vue'import router from './router'import store from './store'import './assets/css/global.css'import settings from './assets/js/settings'import axios from 'axios'import cookies from 'vue-cookies'import ElementUI from 'element-ui'import 'element-ui/lib/theme-chalk/index.css'import 'bootstrap'import 'bootstrap/dist/css/bootstrap.min.css'Vue.prototype.$settings = settingsVue.prototype.$cookies = cookiesVue.prototype.$axios = axiosVue.config.productionTip = falseVue.use(ElementUI);new Vue({ router, store, render: h => h(App)}).$mount('#app')

关键词:前台

74
73
25
news

版权所有© 亿企邦 1997-2025 保留一切法律许可权利。

为了最佳展示效果,本站不支持IE9及以下版本的浏览器,建议您使用谷歌Chrome浏览器。 点击下载Chrome浏览器
关闭