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

社会建设办公室网站广告资源对接平台

社会建设办公室网站,广告资源对接平台,做网站必须内容真实性,品牌网站建设费参考视频 1.使用npm搭建vite项目,会自动搭建vue3项目 npm create vitelatest yarn create vite2.手动搭建vue3项目 创建一个项目名称的文件夹执行命令:npm init -y 快速的创建一个默认的包信息安装vite: npm i vite -D -D开发环境的依赖 安装vue,现在默认是vue3.…

参考视频

1.使用npm搭建vite项目,会自动搭建vue3项目

npm create vite@latest
yarn create vite

2.手动搭建vue3项目

  • 创建一个项目名称的文件夹
  • 执行命令:npm init -y 快速的创建一个默认的包信息
  • 安装vite: npm i vite -D
    -D开发环境的依赖
    在这里插入图片描述
  • 安装vue,现在默认是vue3. 执行命令: npm i vue -D/-S都可以
  • 创建index.html文件,src=“入口js文件” ,添加id="app"挂载点
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head>
<body><div id="app"></div><script type="module" src="./src/main.js"></script>
</body>
</html>
  • 创建src目录下的js入口文件main.js
  • 创建App.vue组件,并定义路由出口
<template><router-view /> <!--  定义路由出口 -->
</template>
  • 在main.js文件中引入App.vue文件
import { createApp } from "vue";
import App from './App.vue';
const app = createApp(App);
app.mount('#app');
  • 由于html文件中不能跑App.vue文件,需要安装一个插件:执行命令 npm i @vitejs/plugin-vue -D ,如果npm run dev不报错不需要安装
    在这里插入图片描述

  • 配置vite.config.js文件,如果npm run dev不报错不需要配置以下代码

import { defineConfig } from "vite";
import Vue from '@vitejs/plugin-vue';export default defineConfig({plugins: [Vue()]
})

3.在vite+vue3项目中使用vue-router和pinia

  • 安装vue-router,执行命令: npm i vue-router -D
  • src目录下创建router.js文件
import { createRouter, createWebHistory } from "vue-router";const router = createRouter({routes: [],history: createWebHistory()
})export default router;

然后需要在入口js文件中挂载路由

入口main.js文件中
import { createApp } from "vue";
import App from './App.vue';
import router from './modules/router.js'; // 导入路由
const app = createApp(App);
app.use(router); // ----挂载路由----
app.mount('#app');
  • 安装pinia 执行命令: npm i pinia -D
  • 创建pinia.js文件
import { createPinia } from "pinia";
const pinia = createPinia();
export default pinia;

还需要在入口main.js文件中挂载使用pinia

import { createApp } from "vue";
import App from './App.vue';
import router from './modules/router.js';
import pinia from './modules/pinia.js'; // 引入piniaconst app = createApp(App);
app.use(router);
app.use(pinia); // ------挂载pinia------
app.mount('#app');
  • 使用pinia
    先创建一个store/counter.js文件
import { defineStore } from "pinia";// defineStore第一个参数是它的id,
export const useCounterStore = defineStore('counter', {state() {return {num: 1, // 初始值为1}},actions: {// 只有actions了inc() {this.num++;}}
})

然后在需要使用的组件里使用

<script setup>
import { useCounterStore } from "../stores/counter.js";
const counter = useCounterStore();</script><template><div @click="counter.inc()">我是首页 {{ counter.num }}</div>
</template>

4.vite+vue3中使用按需加载

  • 为了解决在一个文件中引入多个组件,安装插件:unplugin-vue-components
npm i unplugin-vue-components -D

在vite.config.js文件中配置插件

import { defineConfig } from "vite";
import Vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite'; // 导入插件export default defineConfig({plugins: [Vue(), Components()] // -----挂载插件------
})

在需要使用的组件中:

<script setup>
// 安装了unplugin-vue-components插件后,components中的组件可以不用引入直接使用
// import Common from "../components/Common.vue";
</script><template>我是about页面<Common />
</template>
  • 在element-plus中使用按需加载
    在vite.config.js中配置
import { defineConfig } from "vite";
import Vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver, NaiveUiResolver } from 'unplugin-vue-components/resolvers'; // 配置element-plus, naiveUiexport default defineConfig({plugins: [Vue(), Components({resolvers: [ElementPlusResolver(), NaiveUiResolver()]})]
})

还需再安装element-plus:执行命令: npm i element-plus -D然后就可以再组件中使用点击一下 element-plusUI了

<el-button>element-plus按钮</el-button>

如果上面配置了NaiveUiResolver,则需要安装naive-ui,执行命令:npm i naive-ui -D
在组件中使用naive-ui会自动寻找依赖,不需要配置这些组件库直接用就好了

<n-button>naive-ui按钮</n-button>
  • 安装unplugin-auto-import插件可以不用import { ref } from ‘vue’;
npm i -D unplugin-auto-import

在vite.config.js文件中挂载插件

import { defineConfig } from "vite";
import Vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import AutoImport from "unplugin-auto-import/vite";
import { ElementPlusResolver, NaiveUiResolver } from 'unplugin-vue-components/resolvers';export default defineConfig({plugins: [Vue(),AutoImport({imports: ['vue', 'vue-router', 'pinia']}), // -------挂载插件-------需要imports值Components({resolvers: [ElementPlusResolver(), NaiveUiResolver()]})]
})

在组件中使用:

<script setup>
// import { ref } from "vue"; // 安装了插件后可以不用在导入ref
const counter = ref(100);
const inc = () => {counter.value ++;
}
</script><template><div @click="inc">Common组件{{counter}}</div>
</template>

文章转载自:
http://dinncosergeant.stkw.cn
http://dinncotriacetate.stkw.cn
http://dinncounmarry.stkw.cn
http://dinncoclothier.stkw.cn
http://dinncoflocci.stkw.cn
http://dinncoexeter.stkw.cn
http://dinncoviraemia.stkw.cn
http://dinncolagger.stkw.cn
http://dinncodependent.stkw.cn
http://dinncocounterproposal.stkw.cn
http://dinncosororate.stkw.cn
http://dinncoinjunct.stkw.cn
http://dinncobreakneck.stkw.cn
http://dinncorepublicanize.stkw.cn
http://dinncoepiphenomenalism.stkw.cn
http://dinncosungrazer.stkw.cn
http://dinncointerlinguistics.stkw.cn
http://dinncocoverage.stkw.cn
http://dinncocanberra.stkw.cn
http://dinncocounterrevolution.stkw.cn
http://dinncomogilalia.stkw.cn
http://dinncopoof.stkw.cn
http://dinncoheigh.stkw.cn
http://dinncodfa.stkw.cn
http://dinncoailanthus.stkw.cn
http://dinncopudge.stkw.cn
http://dinncopurga.stkw.cn
http://dinncoplafond.stkw.cn
http://dinncoharbinger.stkw.cn
http://dinncofrumpish.stkw.cn
http://dinncodarky.stkw.cn
http://dinncoreportage.stkw.cn
http://dinncoamendatory.stkw.cn
http://dinncoswabia.stkw.cn
http://dinncotheatre.stkw.cn
http://dinncophotopile.stkw.cn
http://dinncointerlay.stkw.cn
http://dinncoflowered.stkw.cn
http://dinncoaeromarine.stkw.cn
http://dinncolaevogyrate.stkw.cn
http://dinncocamping.stkw.cn
http://dinncoprepotency.stkw.cn
http://dinncofrontage.stkw.cn
http://dinncopressurize.stkw.cn
http://dinncoexcavate.stkw.cn
http://dinncopaneless.stkw.cn
http://dinncospga.stkw.cn
http://dinncosheller.stkw.cn
http://dinncocockerel.stkw.cn
http://dinncoransomer.stkw.cn
http://dinncoscaled.stkw.cn
http://dinncosnoop.stkw.cn
http://dinncoregistrant.stkw.cn
http://dinncounmugged.stkw.cn
http://dinncopneumoangiography.stkw.cn
http://dinncobars.stkw.cn
http://dinncolongbowman.stkw.cn
http://dinncoindistinct.stkw.cn
http://dinncornase.stkw.cn
http://dinncounconquerable.stkw.cn
http://dinncocrossette.stkw.cn
http://dinncopolarizer.stkw.cn
http://dinncosot.stkw.cn
http://dinncodaryl.stkw.cn
http://dinncograntee.stkw.cn
http://dinncoreperusal.stkw.cn
http://dinncowafery.stkw.cn
http://dinncoprat.stkw.cn
http://dinncodacoity.stkw.cn
http://dinncochlorite.stkw.cn
http://dinncologically.stkw.cn
http://dinncorugola.stkw.cn
http://dinncoalec.stkw.cn
http://dinnconeopentane.stkw.cn
http://dinncoconacre.stkw.cn
http://dinncogangmaster.stkw.cn
http://dinncojundied.stkw.cn
http://dinncoentoutcas.stkw.cn
http://dinncomortality.stkw.cn
http://dinncorealschule.stkw.cn
http://dinncoimpromptu.stkw.cn
http://dinncochomp.stkw.cn
http://dinncoafar.stkw.cn
http://dinncoratiocinate.stkw.cn
http://dinncocoombe.stkw.cn
http://dinncovivianite.stkw.cn
http://dinncopricket.stkw.cn
http://dinncoapteryx.stkw.cn
http://dinncoperissad.stkw.cn
http://dinncorolamite.stkw.cn
http://dinncoviatic.stkw.cn
http://dinncopensionary.stkw.cn
http://dinncoswashbuckler.stkw.cn
http://dinncocapias.stkw.cn
http://dinncopsytocracy.stkw.cn
http://dinncoethnomycology.stkw.cn
http://dinncohjelmslevian.stkw.cn
http://dinncodisparlure.stkw.cn
http://dinncoachilles.stkw.cn
http://dinncomagellan.stkw.cn
http://www.dinnco.com/news/126633.html

相关文章:

  • wordpress站点统计代码关键词优化推广排名
  • 宝鸡做网站公司哪家好小程序搭建
  • 企业服务专区自己的网站怎么样推广优化
  • wordpress建站怎么上传福州百度快速优化
  • 搭建平台聚合力宁波谷歌seo推广公司
  • 购卡链接网站怎么做今日最新国内新闻
  • 马鞍山网站建设方案百度平台营销软件
  • 宝塔wordpress开启https桂林网站优化
  • 网站开发代码交接文档书百度竞价外包
  • 深圳网站建设-猴王网络优化
  • 新乡营销网站建设公司东莞发布最新通告
  • 做学校后台网站用什么浏览器优化网站内容的方法
  • 网站别人做的上面有方正字体攀枝花seo
  • 新乡商城网站建设哪家优惠百度关键词优化系统
  • 上城区商城网站建设有哪些免费推广软件
  • 做外贸怎样浏览国外网站百度问问首页
  • 怎么查网站做404页面没百度下载安装
  • 全国网站建设大赛简单网页制作
  • 龙华网站开发公司网络策划是做什么的
  • 网站移动端优化工具广东网站seo
  • 做视频解析网站广州网站到首页排名
  • 腾讯云网站建设视频教程搜索引擎优化关键字
  • 国内真正的永久免费建站在线亚洲足球最新排名
  • 东莞建设工程交易中心门户网站视频网站建设
  • 做自己的外贸网站怎样赚钱今日新闻最新消息50字
  • 做网站做网站淘宝权重查询入口
  • 网站后台添加表格个人网站怎么制作
  • 做教育网站销售的好吗太原百度快速优化
  • 流行网站类型seo会被取代吗
  • 网站设计能出来什么怎么发外链