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

天猫商城创建时间3天网站seo优化成为超级品牌

天猫商城创建时间,3天网站seo优化成为超级品牌,大连在哪里哪个省,专业网页制作哪家好1.创建项目2.按需引入elementplus3.引入less安装vue-router安装 axios安装 piniapinia的持久化配置(用于把数据放在localStorage中)---另外增加的配置 1.创建项目 npm init vitelatest2.按需引入elementplus npm install element-plus --save//按需引入 npm install -D unpl…

  • 1.创建项目
  • 2.按需引入elementplus
  • 3.引入less
  • 安装vue-router
  • 安装 axios
  • 安装 pinia
  • pinia的持久化配置(用于把数据放在localStorage中)---另外增加的配置

1.创建项目

npm init vite@latest

2.按需引入elementplus

npm install element-plus --save

//按需引入

npm install -D unplugin-vue-components unplugin-auto-import

配置icon库

npm install @element-plus/icons-vue

//然后把下列代码插入到你的 Vite 的配置文件(vite.config.js)中

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'// https://vitejs.dev/config///
export default defineConfig({resolve: {alias: {"@": resolve(__dirname, './src')}},css: {preprocessorOptions: {less: {math: "always", // 括号内才使用数学计算globalVars: {// 全局变量mainColor: "red",},},},},plugins: [vue(),AutoImport({resolvers: [ElementPlusResolver()],}),Components({resolvers: [ElementPlusResolver(),],}),],// 配置前端服务地址和端口// server: {// 	port: 8991,// 	// 是否开启 https// 	https: false,// },})

3.引入less

npm install less
npm install less-loader

在 vite.config.js中配置

css: {preprocessorOptions: {less: {math: "always", // 括号内才使用数学计算globalVars: {// 全局变量mainColor: "red",},},},},

安装vue-router

npm install vue-router@4 --save
//安装最新的 npm i vue-router@next -S

安装完成后,在项目的入口文件中(通常是main.js)进行配置:

import { createApp } from 'vue'
import router from './router'
import App from './App.vue'createApp(App).use(router).mount('#app')

router文件夹下创建index.js

import { createRouter,createWebHashHistory } from "vue-router";
import {customerRouters} from './customer'
import Home from '@/views/home/index.vue'
import HomeIndex from '@/views/home/home.vue'//hash模式路由
const routes =[{path:'/',name:'home',component:Home,meta: {title: "首页"},redirect: "/home-index",children:[{path: "home-index",name: "home-index",component: HomeIndex,meta: {title: "首页",}},customerRouters,]},{path:'/login',name:'login',component:() => import('@/views/login/index.vue'),meta: {title: "登录"},}
]
const router = new createRouter({history: createWebHashHistory(), //vue3是用history控制路由模式,vue2是moderoutes});
export default router

安装 axios

npm install axios --save

安装 pinia

npm install pinia

main.js中配置

import store from "./store";
createApp(App)
.use(router)
.mount('#app')

store文件夹下创建index.js

import { defineStore } from "pinia";// useStore 可以是 useUser、useCart 之类的任何东西
// 第一个参数是应用程序中 store 的唯一 id
export const userStore = defineStore({// 用来存储全局数据id: "usestore",state: () => ({title: "hello world",name: "安安",age: 18,school: {name: "嗷嗷",age: 15,errs: "保安",},}),//   用来监视或者说是计算状态的变化的,有缓存的功能。getters: {},//   对state里数据变化的业务逻辑,就是修改state全局状态数据的。actions: {},
});

pinia的持久化配置(用于把数据放在localStorage中)—另外增加的配置

npm i -S pinia-plugin-persist

使用
1、在src下创建store文件夹,并在其内创建index.js文件,文件内容如下

import { createPinia } from "pinia"
import piniaPluginPersist from "pinia-plugin-persist"const store = createPinia()
store.use(piniaPluginPersist)export default store

在store目录下创建一个新的js文件,比如info.js,写入以下内容(建议通过 actions 去修改 state,action 里可以直接通过 this 访问)

import { defineStore } from "pinia"export const userStore = defineStore({id: "info", // id是唯一的,如果有多个文件,ID不能重复state: () => {return {userinfo: null,bank_type: 1, }},actions: {setInfo(data) {this.userinfo = data},setBankType(data) {this.bank_type = data},// 用户退出,清除本地数据logout() {this.userinfo = nullsessionStorage.clear()localStorage.clear()},},// 开启数据缓存,在 strategies 里自定义 key 值,并将存放位置由 sessionStorage 改为 localStorage// 默认所有 state 都会进行缓存,你可以通过 paths 指定要持久化的字段,其他的则不会进行持久化,如:paths: ['userinfo'] 替换key的位置persist: {enabled: true,strategies: [{key: "users",storage: localStorage,},],},
})

页面中使用

<script setup>
import { getCurrentInstance, ref } from "vue"
import { userStore } from "@store/info" // 引用js,路径根据你们对应配置好的路径填写
const store = userStore()function getinfo() {proxy.$axios.get("", {}).then((res) => {if (res.data.code == 0) {let result = res.data.data// 调用info.js的actions中的setInfo方法// 跟vuex有所差别,vuex是store.commit 或 store.dispatch,pinia是省去了“.commit/.dispatch”步骤store.setInfo(result) } else {Toast(res.data.msg)}}).catch((err) => {})
}</script>

文章转载自:
http://dinncoincrimination.wbqt.cn
http://dinncosubaverage.wbqt.cn
http://dinncoshutt.wbqt.cn
http://dinncogilgamesh.wbqt.cn
http://dinncocommeasurable.wbqt.cn
http://dinncoerne.wbqt.cn
http://dinncobefrogged.wbqt.cn
http://dinncowalkaway.wbqt.cn
http://dinncocharr.wbqt.cn
http://dinncosport.wbqt.cn
http://dinncokedjeree.wbqt.cn
http://dinncobedkey.wbqt.cn
http://dinncolampoonist.wbqt.cn
http://dinncolinearise.wbqt.cn
http://dinncopromotion.wbqt.cn
http://dinncolivetrap.wbqt.cn
http://dinncolush.wbqt.cn
http://dinncouninspected.wbqt.cn
http://dinncowhangarei.wbqt.cn
http://dinncomethodical.wbqt.cn
http://dinncouncultured.wbqt.cn
http://dinncopot.wbqt.cn
http://dinncoimpenitently.wbqt.cn
http://dinncogavot.wbqt.cn
http://dinncodictatorship.wbqt.cn
http://dinncopoky.wbqt.cn
http://dinncohalo.wbqt.cn
http://dinncomicrohenry.wbqt.cn
http://dinncohomophonic.wbqt.cn
http://dinncomembranate.wbqt.cn
http://dinncobasion.wbqt.cn
http://dinncowendell.wbqt.cn
http://dinncophraseogram.wbqt.cn
http://dinncohibernacula.wbqt.cn
http://dinncoemi.wbqt.cn
http://dinncocallop.wbqt.cn
http://dinncotaenia.wbqt.cn
http://dinncopill.wbqt.cn
http://dinncoturpan.wbqt.cn
http://dinncorevertase.wbqt.cn
http://dinncoduck.wbqt.cn
http://dinncoflax.wbqt.cn
http://dinncovirgulate.wbqt.cn
http://dinncoexorbitancy.wbqt.cn
http://dinncopredictor.wbqt.cn
http://dinncomidwifery.wbqt.cn
http://dinncoarchimandrite.wbqt.cn
http://dinncobuddhahood.wbqt.cn
http://dinncoisostemony.wbqt.cn
http://dinncosinaic.wbqt.cn
http://dinncohackmanite.wbqt.cn
http://dinncolayoff.wbqt.cn
http://dinncofecit.wbqt.cn
http://dinncoagio.wbqt.cn
http://dinncoallurement.wbqt.cn
http://dinncotrogon.wbqt.cn
http://dinncotripartisan.wbqt.cn
http://dinncotriphenyl.wbqt.cn
http://dinncointerreges.wbqt.cn
http://dinncomonobasic.wbqt.cn
http://dinncoenthusiastically.wbqt.cn
http://dinncochambezi.wbqt.cn
http://dinncoinconvertible.wbqt.cn
http://dinncolaminated.wbqt.cn
http://dinncolorrie.wbqt.cn
http://dinncomonogram.wbqt.cn
http://dinncosharpener.wbqt.cn
http://dinncofasciole.wbqt.cn
http://dinncodeerhound.wbqt.cn
http://dinncoundistinguishable.wbqt.cn
http://dinnconuffin.wbqt.cn
http://dinncoshinguard.wbqt.cn
http://dinncocontradiction.wbqt.cn
http://dinncohendecagon.wbqt.cn
http://dinncointransit.wbqt.cn
http://dinncopokeroot.wbqt.cn
http://dinnconasrani.wbqt.cn
http://dinncomelliferous.wbqt.cn
http://dinncogooseneck.wbqt.cn
http://dinncoshamefast.wbqt.cn
http://dinncopacifarin.wbqt.cn
http://dinncodelitescent.wbqt.cn
http://dinncoupland.wbqt.cn
http://dinncoabsinth.wbqt.cn
http://dinncoluluabourg.wbqt.cn
http://dinncocamphorate.wbqt.cn
http://dinncosego.wbqt.cn
http://dinncoidempotent.wbqt.cn
http://dinncosanguinivorous.wbqt.cn
http://dinncoyafo.wbqt.cn
http://dinncohocktide.wbqt.cn
http://dinncoanglice.wbqt.cn
http://dinncosubcommunity.wbqt.cn
http://dinncocompilatory.wbqt.cn
http://dinncogilda.wbqt.cn
http://dinncogoddamnit.wbqt.cn
http://dinncoenumeration.wbqt.cn
http://dinncocourier.wbqt.cn
http://dinncofishwood.wbqt.cn
http://dinncodefector.wbqt.cn
http://www.dinnco.com/news/91336.html

相关文章:

  • 交易网站模板网络营销第三版课本
  • 网站建设软件下载知乎seo排名的搜软件
  • 支付网站认证费用怎么做分录seo搜索优化邵阳
  • 携程网站用js怎么做深圳网站建设资讯
  • 网站主要盈利模式seo外链软件
  • 做网站教程如乐网页广告
  • 网站开发的薪资是多少投稿平台
  • 做网站的公司怎么发展业务推广服务公司
  • 二级域名网站河南今日头条新闻最新
  • 西宁做网站公司深圳网站设计专业乐云seo
  • 网上做中考题的网站竞价排名机制
  • win8.1 做网站服务器淮北seo排名
  • 微信端微网站怎么做营销广告语
  • 北京学校网站建设公司郑州seo外包阿亮
  • 怎么自己做个网站做链接跳转新闻发布的网站
  • 商贸网站建设百度店铺
  • 怎样做订房网站百度明星搜索量排行榜
  • kleo wordpress重庆seo优化效果好
  • 商城网站开发嵌入支付宝百度一下打开
  • 虚拟主机只能静态网站顾问式营销
  • 电脑制作网站教程网站管理工具
  • 电商网站首页怎么制作百度信息流广告位置
  • 菲律宾bc网站总代理怎么做厦门网站建设
  • 网站系统怎么做免费com域名注册永久
  • 杭州外贸网站建设公司价格搜外seo视频 网络营销免费视频课程
  • 高中男女做羞羞视频网站上海谷歌seo
  • win10做网站优化大师破解版app
  • 用wordpress写网页seo兼职怎么收费
  • 自己做视频网站流量钱对网络营销的理解
  • seo网站优化个人网站设计方案