ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

vue.js3: 使用全局css样式文件(vue@3.2.37)

2022-07-15 23:04:00  阅读:203  来源: 互联网

标签:vue app 37 element plus js3 import css


一,创建全局css文件

创建global.css文件,保存全局样式,如图:   global.css的代码:

.titleDiv { width:800px; text-shadow: 2px 2px 5px #777; line-height: 22px; font-size: 22px; color: rgb(90, 90, 90); margin-top: 20px; } .mainDiv { width:800px; margin: auto; } .panel { border-color:#eeeeee; border-radius:10px; border-style:solid; border-width:1px; width:800px; background:rgb(250,250,250); display: flex; flex-direction: column; margin-top: 20px; margin-bottom: 10px; }

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

二,main.js中引入样式:

main.js
import { createApp } from 'vue'
import App from './App.vue'
import router from './route'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//element-plus 的中文化
import locale from 'element-plus/lib/locale/lang/zh-cn' 
//element-plus 的icon
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
//引入css公共样式
import '../public/static/css/global.css' 
//启动app
const app = createApp(App)

// 全局注册el-icon
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(router)
app.use(ElementPlus,{locale})
app.mount('#app')

三,使用样式

Base64.vue
<template>
<div >
  <div class="mainDiv">
  <div class="titleDiv" style="line-height: 24px;font-size: 24px;color: #777;margin-top: 20px;">
    BASE64编码/解码
  </div>
  <div class="panel" style="">

    <div style="margin-left:30px;display: flex;flex-direction: row;margin-top:20px;margin-bottom:20px;">
    <el-input
        ref="plain"
        v-model="plainText"
        :rows="9"
        type="textarea"
        placeholder="请输入要做base64编码的文本"
        style="width:300px;"
    />
    <div style="width:140px;">
    <el-button type="info" plain @click="encode">BASE64编码&gt;</el-button>
    <el-button type="info" plain style="margin-top: 20px;margin-left: 0px;" @click="decode">&lt;BASE64解码</el-button>
    </div>
    <el-input
        ref="base64"
        v-model="base64Text"
        :rows="9"
        type="textarea"
        placeholder="经过base64编码的文本"
        style="width:300px;"
    />
    </div>
  </div>
  </div>
</div>
</template>

四,测试效果

 

五,查看vue框架的版本: 

liuhongdi@lhdpc:/data/vue/child$ npm list vue
child@0.1.0 /data/vue/child
├─┬ @vue/cli-plugin-babel@5.0.6
│ └─┬ @vue/babel-preset-app@5.0.6
│   └── vue@3.2.37 deduped
└─┬ vue@3.2.37
  └─┬ @vue/server-renderer@3.2.37
    └── vue@3.2.37 deduped

 

标签:vue,app,37,element,plus,js3,import,css
来源: https://www.cnblogs.com/architectforest/p/16483008.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有