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

山东省无障碍网站建设标准中国宣布进入战时状态会怎样

山东省无障碍网站建设标准,中国宣布进入战时状态会怎样,长沙哪家网站建设比较好,网站运营经验分享ppt打造自己的前端组件库 demo是开源的,自己上npm 或者 github 上都能搜到 新建vue项目(sass js vue2) vue create yt-ui 修改文件目录(如下) 修改: 1.src 更名 examples; 2. src/components移动到项目最外层;3.vue.config.js更改入口文件 /…

打造自己的前端组件库

demo是开源的,自己上npm 或者 github 上都能搜到

新建vue项目(sass + js + vue2)

vue create yt-ui	

修改文件目录(如下)

在这里插入图片描述

修改: 1.src 更名 examples; 2. src/components移动到项目最外层;3.vue.config.js更改入口文件

// vue.config.js
const {defineConfig} = require('@vue/cli-service')
module.exports = defineConfig({transpileDependencies: true,pages: {index: {entry: 'examples/main.js',template: 'public/index.html',filename: 'index.html'}}
})

编写ytDemo组件并在app.vue中使用

在这里插入图片描述

新建文件目录结构如上图:

 // components/demo/index.jsimport ytDemo from "./src/main.vue";ytDemo.install = (Vue) => {Vue.component(ytDemo.name, ytDemo);};export default ytDemo;// components/src/main.vue<!--* @Description: main 页面* @Author: mhf* @Date: 2023/10/21--><template><div><div class="a">a<div class="b">b</div></div></div></template><script>export default {name: "ytDemo",components: {},props: {},computed: {},watch: {},filters: {},data() {return {};},methods: {},created() {},mounted() {},destroyed() {},};</script><style lang="scss" scoped>.a {width: 200px;height: 200px;border: 1px solid red;.b {width: 100px;height: 100px;border: 1px solid green;}}</style>// example/main.jsimport Vue from 'vue'import App from './App.vue'import ytDemo from "../components/ytDemo";Vue.use(ytDemo)Vue.config.productionTip = falsenew Vue({render: h => h(App),}).$mount('#app')

根据如上步骤则出现如下效果
在这里插入图片描述


打包

// components/index.js// 整个包的入口
// 统一导出
import ytComp from "./ytComp";
import ytDemo from "./ytDemo";
const components = [ytComp,ytDemo,
]
// 定义install方法
const install = function (Vue) {// 注册所有的组件components.forEach(component => {Vue.component(component.name, component)})
}
// 判断是否直接引入文件,如果是,就不用调用Vue.use()
if (typeof window !== 'undefined' && window.Vue) {install(window.Vue)
}
// 导出install方法
export default {install,ytDemo,ytComp
}// package.json
{"name": "@mhfwork/yt-ui", // 必须保持唯一(请自行上npm官网查询自己的项目名称)"version": "0.0.1","private": false,"author": {"name": "毛三仙","email": "mhf.mail@qq.com"},"scripts": {"serve": "vue-cli-service serve","build": "vue-cli-service build","lint": "vue-cli-service lint","format": "prettier --write \"components/**/*.js\" \"components/**/*.vue\" \"examples/**/*.vue\" \"examples/**/*.vue\"","lib": "vue-cli-service build --target lib components/index.js"},"dependencies": {"core-js": "^3.8.3","vue": "^2.6.14"},"devDependencies": {"@babel/core": "^7.12.16","@babel/eslint-parser": "^7.12.16","@vue/cli-plugin-babel": "~5.0.0","@vue/cli-plugin-eslint": "~5.0.0","@vue/cli-service": "~5.0.0","eslint": "^7.32.0","eslint-plugin-vue": "^8.0.3","sass": "^1.32.7","sass-loader": "^12.0.0","vue-template-compiler": "^2.6.14"},"eslintConfig": {"root": true,"env": {"node": true},"extends": ["plugin:vue/essential","eslint:recommended"],"parserOptions": {"parser": "@babel/eslint-parser"},"rules": {}},"browserslist": ["> 1%","last 2 versions","not dead"]
}

发布流程

todo: 更新 readeMe.md、package.json版本号   1. npm run lib   2. npm get registry 3. npm login     					// 登陆自己的npm账号,没有请自行注册4. npm publish --access public		// 正常的话 npm publish 即可,因本项目中使用@mhfwork/xxx 需注明是public库

使用发布成功的组件库
在这里插入图片描述

新项目中

npm i @mhfwork/yt-ui
main.js中注册	import ytComp from "@mhfwork/yt-ui/components/ytComp";import ytDemo from "@mhfwork/yt-ui/components/ytDemo";Vue.use(ytComp)Vue.use(ytDemo)	

Vue文件中使用

<template><div class="home"><yt-comp page-name="aaahahah"/><yt-demo /></div>
</template><script>
// @ is an alias to /srcexport default {name: 'HomeView',components: {}
}
</script>
http://www.yayakq.cn/news/873944/

相关文章:

  • 多语言网站环保工程 技术支持 东莞网站建设
  • 建立一个网站需要多久wordpress重写内置函数
  • 网站建设 博采wordpress推荐适合seo的主题
  • 射阳做企业网站哪家好贵州网站建设
  • 大连哪家公司做网站好安庆网站建设兼职
  • 网站上的搜索怎么做定制安卓app多少钱
  • 卖磁铁的网站怎么做佛山网站建设优化企业
  • 北京网站建设有限公司上海app开发定制
  • 网站设计咨询电话阿里云wordpress建站教程
  • 高端网站建设的介绍广州安全教育平台入口登录官网
  • 找人做网站安全吗手机网站单页面
  • 制作网站的收获体会免费在线观看高清影片
  • 外贸网站建设需要注意事项网络设计的步骤
  • 专业网站设计怎么做网站根目录怎么写
  • 做淘宝店铺标志的网站一定seo自己网站吗
  • 网站优化软件排名少儿编程收费价目表
  • 做任务拍照片赚钱的网站网站开发做什么科目
  • 兼职做网站编辑wordpress微信支付后开通会员
  • 网站推广100种方法设计师发布作品的网站
  • 官方制作网站专业制作银行存单
  • 如何将下载好的网站模板用到织梦程序上dw制作网页的过程
  • 重庆做手机网站建设你的安全设置不允许网站
  • 贵州省建设厅网站多少恩施网站建设
  • 帮人做推广的网站境外 网站网站
  • 广州网站建设出名 乐云践新网站地图的制作
  • 郑州做品牌网站好的公司盘锦做网站选哪家好
  • 自动发货网站建设手机访问wordpress慢
  • 网站维护一般需要多久时间南京 电子商务网站
  • 贵阳网站建设方舟网络苏州建设工程人才招聘网信息网站
  • 网站推广好不好广州白云区公司注册