第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

【學(xué)習(xí)打卡】第1天 搭建Vue3+Vite+TS項(xiàng)目

標(biāo)簽:
vuex Typescript

课程名称:基于Vue3+Vite+TS,二次封装element-plus业务组件

课程章节:封装组件初级篇(上)

主讲老师:五月的夏天


课程内容:

今天学习的内容包括:

2-2 搭建vite项目并配置路由和element-plus——使用vite搭建基本模板,安装路由,引入element-plus。

2-3 全局注册图标——安装@element-plus/icons依赖,引入并全局注册。


课程收获:

搭建vue3+vite+ts项目

npm create vite@latest my-vue-app -- --template vue-ts

安装和配置路由router

// 安装
npm i vue-router@next -S

// 配置
import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'
import Home from '@/views/Home.vue'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: Home
  }
]

const router = createRouter({
  routes,
  history: createWebHistory()
})

export default router

安装及引入element-plus

// 安装
npm install element-plus --save 

// 引入
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
app.use(ElementPlus)

安装@element-plus/icon并全局注册

// 安装
npm install @element-plus/icons-vue

// 注册
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  // app.component(key, component)
  app.component(`el-icon-${toLine(key)}`, component) // 此处为驼峰转横杠
}

学习到了驼峰转横杠正则写法

export const toLine = (value:string) => {
  return value.replace(/(A-Z)g/, '-$1').toLocaleLowerCase()
}


使用vite编译工具运行实在太快了,秒开,终于不用等待很久了。

学到了两个好方法:

1、Object.entries()可以将对象转为数组[key,value]

2、value.replace(/(A-Z)g/,'-$1'),可以匹配需要内容使用$1进行拼接等处理


坚持打卡,坚持学习,未来可期,加油😀。


个人思考:能否把svg图标全局注册并使用?明天尝试下😀


https://img3.sycdn.imooc.com/62e9236900011c0619200897.jpg


https://img4.sycdn.imooc.com/62e92a2d0001336a19200897.jpg




點(diǎn)擊查看更多內(nèi)容
1人點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報(bào)

0/150
提交
取消