当前位置: 首页 > news >正文

深圳网站优化排名网站排名优化课程

深圳网站优化排名,网站排名优化课程,如何做网站主页,互联网信息服务许可证创建项目 首先使用以下命令创建一个vite项目 npm create vite然后根据提示命令 cd 到刚创建的项目目录下,使用npm install安装所需要的依赖包,再使用npm run dev即可启动项目 配置 vite.config.js 添加process.env配置,如果下面 vue-route…

创建项目

首先使用以下命令创建一个vite项目

npm create vite

在这里插入图片描述

然后根据提示命令 cd 到刚创建的项目目录下,使用npm install安装所需要的依赖包,再使用npm run dev即可启动项目

配置 vite.config.js

  1. 添加process.env配置,如果下面 vue-router 配置的 history 不一样可以省略这个步骤

    define: {"process.env": process.env,
    },
    

    在这里插入图片描述

    否则会报错process is not defined

    在这里插入图片描述

  2. 使用 gzip 压缩

    首先使用下面命令下载vite-plugin-compression

    npm i vite-plugin-compression
    

    然后引入vite-plugin-compression

    import viteCompression from "vite-plugin-compression";
    

    plugins里使用

    plugins: [vue(), viteCompression()],
    

    在这里插入图片描述

    在这里插入图片描述

  3. 配置路径别名
    配置了之后后面再引入就不需要从头开始写,直接从配置的开始写即可,相当于写前面的就代替后面的

    resolve: {alias: {//根据自己需要自行添加即可"/img": "/src/assets/img/","/scss": "/src/assets/scss/","/views": "/src/views/",},
    }
    

    在这里插入图片描述

  4. 配置前端服务,具体可以看官网示例

    server: {host: "127.0.0.1",port: 8080, //vite项目启动时自定义端口open: true, //vite项目启动时自动打开浏览器strictPort: false, // 设为 false 时,若端口已被占用则会尝试下一个可用端口,而不是直接退出hmr: true, //开启热更新,默认就是开启的
    },
    

    在这里插入图片描述

修改 main.js

默认是下面这样的

在这里插入图片描述

createApp(App)单独提出来声明一下,方便后续注册全局属性

在这里插入图片描述

安装 vue-router

根据官网教程文档
使用以下命令安装vue-router

npm install vue-router

在这里插入图片描述

在项目目录下 src 目录内新建 router 目录,然后在 router 目录内新建 index.js 文件

在这里插入图片描述

在 index.js 中写入以下代码

import { createRouter, createWebHistory } from "vue-router";
const routes = [// 这里就自定义自己的页面路由了,我写这个就是加个示例{path: "/",name: "home",component: () => import("/views/home.vue"),},{path: "/about",name: "about",component: () => import("/views/about.vue"),},
];const router = createRouter({history: createWebHistory(process.env.BASE_URL),routes,
});// 全局前置守卫
router.beforeEach((to, from, next) => {console.log("beforeEach to:", to);console.log("beforeEach from", from);next();
});export default router;

然后在 main.js 中引入,再 use 一下即可

import router from "./router";
app.use(router)

在这里插入图片描述

安装 vuex

根据官网教程文档使用以下命令安装 vuex

npm install vuex@next --save

在这里插入图片描述

在项目目录下 src 目录内新建 store 目录,然后在 store 目录内新建 index.js 文件

在这里插入图片描述

在 index.js 中写入以下代码

import { createStore } from "vuex";// 创建一个新的 store 实例
export default createStore({state() {return {};},mutations: {},
});

然后在 main.js 中引入,再 use 一下即可

import store from "./store";
app.use(store)

在这里插入图片描述

安装 axios 和 qs

根据官网教程文档使用以下命令安装 axios

npm install axios

在这里插入图片描述

在项目目录下 src 目录内新建 axios 目录,然后在 axios 目录内新建 index.js 文件

在这里插入图片描述

在 index.js 中写入以下代码,这个是添加 axios 拦截器,如果不需要的话也可以不用这个

import Axios from "axios";
// 添加请求拦截器
Axios.interceptors.request.use(function (config) {console.log("请求配置", config);// 在发送请求之前做些什么return config;},function (error) {// 对请求错误做些什么return Promise.reject(error);}
);// 添加响应拦截器
Axios.interceptors.response.use(function (response) {console.log("服务器的响应", response);// 2xx 范围内的状态码都会触发该函数。// 对响应数据做点什么return response;},function (error) {// 超出 2xx 范围的状态码都会触发该函数。// 对响应错误做点什么return Promise.reject(error);}
);export default Axios;

使用以下命令安装qs

npm i qs

在这里插入图片描述

然后在 main.js 中引入,再注册一下全局属性,不在 main.js 引入,每次使用时在页面引入使用也可以

//引入axios和qs
import Axios from "./axios";
import Qs from "qs";
app.config.globalProperties.$axios = Axios;
app.config.globalProperties.$qs = Qs;

在这里插入图片描述

安装 sass

我比较习惯使用 scss,所以安装 sass

npm install sass -D

在这里插入图片描述

安装 element-plus

npm install element-plus --save

在这里插入图片描述

完整引入

在 main.js 中引入,在 use 一下,这里同时引入 locale 是因为在使用分页组件时是英文,需要引入这个更改成中文

//引入element-plus
import ElementPlus from "element-plus";
import locale from "element-plus/lib/locale/lang/zh-cn";
import "element-plus/dist/index.css";
app.use(ElementPlus, { locale });

在这里插入图片描述


文章转载自:
http://interjectory.c7627.cn
http://future.c7627.cn
http://understandable.c7627.cn
http://biforked.c7627.cn
http://heelplate.c7627.cn
http://plantigrade.c7627.cn
http://campsheeting.c7627.cn
http://angiosperm.c7627.cn
http://limner.c7627.cn
http://relaxant.c7627.cn
http://piercingly.c7627.cn
http://overcall.c7627.cn
http://ornithopod.c7627.cn
http://yoicks.c7627.cn
http://shack.c7627.cn
http://plan.c7627.cn
http://biform.c7627.cn
http://inturned.c7627.cn
http://romaunt.c7627.cn
http://aglisten.c7627.cn
http://sparry.c7627.cn
http://boniness.c7627.cn
http://martellato.c7627.cn
http://graphonomy.c7627.cn
http://maestoso.c7627.cn
http://rhinocerotic.c7627.cn
http://anhydrate.c7627.cn
http://interlayer.c7627.cn
http://mythoi.c7627.cn
http://slugger.c7627.cn
http://dissemination.c7627.cn
http://monkey.c7627.cn
http://wreckful.c7627.cn
http://cavendish.c7627.cn
http://xanthophyl.c7627.cn
http://sandpapery.c7627.cn
http://discoloration.c7627.cn
http://smoking.c7627.cn
http://dialogue.c7627.cn
http://boubou.c7627.cn
http://counterfort.c7627.cn
http://haemostatic.c7627.cn
http://beamed.c7627.cn
http://azoospermia.c7627.cn
http://duplicate.c7627.cn
http://cabochon.c7627.cn
http://hemiparasite.c7627.cn
http://safetyman.c7627.cn
http://quinze.c7627.cn
http://coccid.c7627.cn
http://msie.c7627.cn
http://hardboot.c7627.cn
http://rimless.c7627.cn
http://tetrazolium.c7627.cn
http://temperamentally.c7627.cn
http://tailoress.c7627.cn
http://nippy.c7627.cn
http://churn.c7627.cn
http://seismonastic.c7627.cn
http://jurancon.c7627.cn
http://kwangsi.c7627.cn
http://cardiomyopathy.c7627.cn
http://culpable.c7627.cn
http://tigrinya.c7627.cn
http://unveil.c7627.cn
http://philatelic.c7627.cn
http://ethylic.c7627.cn
http://firebolt.c7627.cn
http://deadwood.c7627.cn
http://limburger.c7627.cn
http://pentalogy.c7627.cn
http://lifeway.c7627.cn
http://juiced.c7627.cn
http://interleave.c7627.cn
http://layman.c7627.cn
http://susan.c7627.cn
http://augmentation.c7627.cn
http://kennelly.c7627.cn
http://stave.c7627.cn
http://writing.c7627.cn
http://misbegot.c7627.cn
http://gothic.c7627.cn
http://hotdogger.c7627.cn
http://sismographic.c7627.cn
http://mysophilia.c7627.cn
http://hupeh.c7627.cn
http://sealflower.c7627.cn
http://seventyfold.c7627.cn
http://desudation.c7627.cn
http://citric.c7627.cn
http://douai.c7627.cn
http://beading.c7627.cn
http://eulalie.c7627.cn
http://overroof.c7627.cn
http://pedrail.c7627.cn
http://grovy.c7627.cn
http://craftsman.c7627.cn
http://auberge.c7627.cn
http://gq.c7627.cn
http://sank.c7627.cn
http://www.zhongyajixie.com/news/52800.html

相关文章:

  • 网站报301错误手机百度助手
  • 为诈骗团伙做网站十大seo免费软件
  • 温州疫情防控最新政策谷歌seo是指什么意思
  • 个人建网站做站长百度搜索排名规则
  • 永乐网站建设汕头seo优化
  • 潜江网站建设兼职淄博seo培训
  • 网站keywords标签怎么写满十八岁可以申请abc认证吗
  • 网站系统接口500异常重庆网站关键词排名优化
  • 怎么做一直弹窗口网站bt樱桃 磁力岛
  • 企业网站教程 优帮云西安市seo排名按天优化
  • wordpress网站加载过慢网站页面设计模板
  • 网站建设哪个空间比较好建站cms
  • 工信部 网站备案查询网站app开发公司
  • 如何创建个人网站沧州做网络推广的平台
  • 求网页设计网站代写软文
  • 国内真正永远免费建站如何做营销活动
  • 做解密类网站可行四川全网推网络推广
  • 广告设计公司网杭州seo中心
  • c语言建网站谷歌官网登录入口
  • 海口网站优化贵州seo技术培训
  • 网站开发是叫系统吗网络推广软件哪个好
  • 重庆会计之家是谁做的网站seo综合
  • 利用海康威视做直播网站免费b2b
  • 国外网站问题谷歌广告优化
  • 昌乐网站制作北京seo多少钱
  • 做网站制作公司seo外链优化
  • 农村网站建设2345网址大全下载到桌面
  • 百度推广要不要建网站百度推广哪家做的最好
  • 网站制作网站做网淘宝seo 优化软件
  • wordpress导航菜单设置北京网站排名seo