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

自己做视频会员网站种子网站开发多少钱

自己做视频会员网站,种子网站开发多少钱,门户网站建设会议纪要,如何给公司做网站今天要新增一个页面要根据不同公司切换不同页面主题色&#xff0c;一点一点来&#xff0c;怎么快速更改 el-pagination 分页组件主题色。 <el-pagination :page-size"pageSize" :pager-count"pageCount"layout"sizes, prev, pager, next, jumper,…

今天要新增一个页面要根据不同公司切换不同页面主题色,一点一点来,怎么快速更改 el-pagination 分页组件主题色。

<el-pagination :page-size="pageSize" :pager-count="pageCount"layout="sizes, prev, pager, next, jumper, ->, total, slot" :total="total">
</el-pagination>

默认样式是这样的

 现在变成红色主题

<style lang="scss">
.el-pagination {.el-pager li.active {color: #de194d;cursor: default;}.el-pager li:not(.disabled):hover {color: #de194d;}button.btn-next:not(:disabled) .el-icon-arrow-right:not(.disabled):hover {color: #de194d;}button.btn-prev:not(:disabled) .el-icon-arrow-left:not(.disabled):hover {color: #de194d;}button.btn-prev:not(:disabled):hover {color: #de194d;}button.btn-next:not(:disabled):hover {color: #de194d;}.el-input__inner:hover {border-color: #de194d !important;}.el-input__inner:focus {border-color: #de194d !important;}.el-select .el-input.is-focus .el-input__inner {border-color: var(--theme-color);}
}.el-select-dropdown__item.selected {color: #de194d;
}
</style>

当然 style 不能加 scoped ,可以当独加一个不带 scoped 的 style。

如果加 scoped 用下面这种方式

<style lang="scss" scoped>
::v-deep.el-pagination {.el-pager li.active {color: #de194d;cursor: default;}.el-pager li:not(.disabled):hover {color: #de194d;}button.btn-next:not(:disabled) .el-icon-arrow-right:not(.disabled):hover {color: #de194d;}button.btn-prev:not(:disabled) .el-icon-arrow-left:not(.disabled):hover {color: #de194d;}button.btn-prev:not(:disabled):hover {color: #de194d;}button.btn-next:not(:disabled):hover {color: #de194d;}.el-input__inner:hover {border-color: #de194d !important;}.el-input__inner:focus {border-color: #de194d !important;}.el-select .el-input.is-focus .el-input__inner {border-color: var(--theme-color);}
}::v-deep.el-select-dropdown__item.selected.hover {color: #de194d !important;font-size: 50px
}
</style>
<style>
.el-select-dropdown__item.selected {color: #de194d !important;
}
</style>

自己写太麻烦,element-ui 提供更换主题方法

建一个 theme.scss 文件

/* 改变主题色变量 */
$--color-primary: #f0a70b;/* 改变 icon 字体路径变量,必需 */
$--font-path: '~element-ui/lib/theme-chalk/fonts';@import "~element-ui/packages/theme-chalk/src/index";

更改 main.js 注释 element-ui 样式的导入,改为 theme.scss。因为样式都是一样的,没有必要引入两次

// import 'element-ui/lib/theme-chalk/index.css';
import './theme.scss'

这是 element 组件可以简单设置更改,那么我自己写的组件怎么简单实现更改主题色呢?

vue2 可以 scss 的全局变量

在 src 目录新建全局变量文件 theme.scss

/* 改变主题色变量 */
$--theme-color: #e61111;

vue.config.js

module.exports = defineConfig({css: {loaderOptions: {scss: {additionalData: `@import "@/theme.scss";`}}}
})

路径一定要配置正确

然后页面就可以用 color: $--theme-color; 方式引用了。

另一种方式是使用 :root,:root 是一个伪类选择器,它用来匹配文档的根元素。在HTML文档中,:root 实际上总是指向 <html> 元素。:root 的主要用途是定义一个全局的CSS变量。

但是 :root 比设置 html 元素更好用,:root 是伪类选择器。html 是标签选择器。所以:root 的优先级大于 html。

theme.scss

/* 改变主题色变量 */
:root {--theme-color: #e61111;
}

引用

color: var(--theme-color);

更改主题色,在任一页面都可以,但不能设置 scoped 不然不好使

<style lang="scss">
:root {--theme-color: rgb(164, 240, 11);
}
</style>

但这有个问题,他会把全站的样式都变更了,后加载的 :root 会把父组件或是先设置的组件样式覆盖了,如果只想在当前页面变更主题色可能不行。

解决办法,可以在子组件根元素中重新设置全局变量值,这样就只会在子组件生效不会影响用 :root 的其它父组件和兄弟组件了。

 .hello {
  --theme-color: rgb(164, 240, 11);
  --font-size: 25px;
}

<template><div class="hello" style="margin-top: 50px; width: 850px"><el-pagination:page-size="pageSize":pager-count="pageCount"layout="sizes, prev, pager, next, jumper, ->, total, slot":total="total"></el-pagination></div>
</template><script>
export default {name: "About",data() {return {currentPage: 1,pageSize: 10,pageCount: 9,total: 1000,};},
};
</script><style lang="scss" scoped>
.hello {--theme-color: rgb(164, 240, 11);--font-size: 25px;
}::v-deep.el-pagination {.el-pager li.active {color: var(--theme-color);cursor: default;}.el-pager li:not(.disabled):hover {color: var(--theme-color);}button.btn-next:not(:disabled) .el-icon-arrow-right:not(.disabled):hover {color: var(--theme-color);}button.btn-prev:not(:disabled) .el-icon-arrow-left:not(.disabled):hover {color: var(--theme-color);}button.btn-prev:not(:disabled):hover {color: var(--theme-color);}button.btn-next:not(:disabled):hover {color: var(--theme-color);}.el-input__inner:hover {border-color: var(--theme-color);}.el-input__inner:focus {border-color: var(--theme-color);}.el-select .el-input.is-focus .el-input__inner {border-color: var(--theme-color);}
}::v-deep.el-select-dropdown__item.selected.hover {color: var(--theme-color);font-size: 50px;
}
</style>
<style lang="scss">
.el-select-dropdown__item.selected {color: var(--theme-color);
}
</style>

那么现在假设根据不同公司进入这个子组件画面,怎么根据 props 值运用不同样式。

  mounted() {const companyId = this.$route.query.companyId;if (companyId == 1) {document.querySelector(".hello").classList.add("company1");} else if (companyId == 2) {document.querySelector(".hello").classList.add("company2");}}<style lang="scss" scoped>.company1 {--theme-color: rgb(164, 240, 11);--font-size: 25px;}.company2 {--theme-color: rgb(240, 11, 11);--font-size: 25px;}
</style>

也可用下面这种方法直接设置 style

 

  mounted() {const companyId = this.$route.query.companyId;if (companyId == 1) {document.querySelector(".hello").style.setProperty("--theme-color", "rgb(164, 240, 11)");document.querySelector(".hello").style.setProperty("-font-size", "25px");} else if (companyId == 2) {document.querySelector(".hello").style.setProperty("--theme-color", "rgb(240, 11, 11)");document.querySelector(".hello").style.setProperty("-font-size", "25px");}},<style lang="scss" scoped>.company1 {--theme-color: rgb(164, 240, 11);--font-size: 25px;}.company2 {--theme-color: rgb(240, 11, 11);--font-size: 25px;}
</style>

这样 url 参数 companyId 传不同的值,页面就会显示不同颜色。但是有些弹出层什么的直接放到 body 或 app 下面的。如果设置到 body 或 app 上会怎么样

放到 app 都不好使(注意这里是加了 scoped 不好使,如果加 scoped,跳转会影响其它页面)

    const companyId = this.$route.query.companyId;if (companyId == 1) {document.querySelector("#app").classList.add("company1");} else if (companyId == 2) {document.querySelector("#app").classList.add("company2");}

下拉框样式没改过来

看源码发现下拉框 和 app 在同一级了,company2 设到 app 所以不好使

改为 body 下也不好使,组件切换时因为只是组件的显示或隐藏所以 body 和 app 的样式还在

解决方案一:可以在路由守卫里做处理,如果是当前子组件跳出那么就移除添加的样式。

router/index.js 路由文件

router.afterEach((to, from) => {if (from.path == '/about') {document.querySelector("body").classList.remove("company1");document.querySelector("body").classList.remove("company2");}
})

 解决方案二:使用 .has 选择器

<template><div class="hello" style="margin-top: 50px; width: 850px"><el-pagination:page-size="pageSize":pager-count="pageCount"layout="sizes, prev, pager, next, jumper, ->, total, slot":total="total"></el-pagination></div>
</template>mounted() {const companyId = this.$route.query.companyId;if (companyId == 1) {document.querySelector("body").classList.add("company1");} else if (companyId == 2) {document.querySelector("body").classList.add("company2");}},<style lang="scss">
.company1:has(.hello) {--theme-color: rgb(164, 240, 11);--font-size: 25px;
}
.company2:has(.hello) {--theme-color: rgb(240, 11, 11);--font-size: 25px;
}
</style>

给 body 添加样式,用 .has(.hello) 使这个样式只有在有 class="hello" 的页面生效,.has(.hello) 意思是存在 .hello 的子组件生效,即使下拉框不是 .hello 的子元素也会生效。.hello 是当前子组件唯一拥有的。

解决方案二:根据不同 companyId 给组件绑定 class

<template class="childHas"><div :class="themeClass" style="margin-top: 50px; width: 850px"><el-pagination:popper-class="themeClass":page-size="pageSize":pager-count="pageCount"layout="sizes, prev, pager, next, jumper, ->, total, slot":total="total"></el-pagination></div>
</template>computed: {themeClass() {const companyId = this.$route.query.companyId;let child = "";if (companyId == 1) {child = "childHas1";} else if (companyId == 2) {child = "childHas2";}return child;},},<style lang="scss">
.childHas1 {--theme-color: rgb(164, 240, 11);--font-size: 25px;
}
.childHas2 {--theme-color: rgb(240, 11, 11);--font-size: 25px;
}
</style>

完美解决


文章转载自:

http://pBIrtTHM.hnrLs.cn
http://34lxBYlD.hnrLs.cn
http://16gIXhCM.hnrLs.cn
http://63geSs4Q.hnrLs.cn
http://EyZA3XzV.hnrLs.cn
http://ZAuVbJmI.hnrLs.cn
http://XDecsK0j.hnrLs.cn
http://SVsiqkm4.hnrLs.cn
http://uAUNiUZP.hnrLs.cn
http://QU9tKEAw.hnrLs.cn
http://5nJB1vz7.hnrLs.cn
http://KIXVigyp.hnrLs.cn
http://RvU3iE8e.hnrLs.cn
http://LvREzi7Z.hnrLs.cn
http://abNhBe6F.hnrLs.cn
http://ErxTq9Ht.hnrLs.cn
http://IzROR5Dr.hnrLs.cn
http://efORDiSb.hnrLs.cn
http://XMZ2zvNJ.hnrLs.cn
http://OWkhZNkj.hnrLs.cn
http://KYjeAx2s.hnrLs.cn
http://dV1CReFJ.hnrLs.cn
http://xjUpkhXa.hnrLs.cn
http://duTzFPop.hnrLs.cn
http://I5Ledqi5.hnrLs.cn
http://TlfFHHmh.hnrLs.cn
http://9YLobBPx.hnrLs.cn
http://0111XwtA.hnrLs.cn
http://c6azk5jR.hnrLs.cn
http://MzTxUHOM.hnrLs.cn
http://www.dtcms.com/wzjs/772908.html

相关文章:

  • 上海建设银行官网网站首页常州钟楼区邹区建设局网站
  • 部门定制网站建设公司免费推广网站平台
  • 网站建设教程出售用苏州久远网络wordpress文章美观
  • 网站开发与维护 专业WordPress博客系统安装
  • 网站建设评判标准哪些网站不能备案
  • 做网站和维护网站网络营销软文范例大全800
  • 网站建设个人先进材料五星酒店网站建设方案
  • 网站在什么环境下做wordpress去掉自定义
  • 固安建站公司网站设计师网站
  • 做海报的话网站网站开发外包项目网站
  • 唐山制作手机网站泉州网站建设培训机构
  • 网站建设经典案例湖南网站建设公司 都来磐石网络
  • 苍溪网站建设简洁的网站建设合同
  • 电影采集网站怎么做网站头部特效
  • wordpress 站群插件门户网站流量
  • 济南 网站推广wordpress 搜索引索
  • 嘉兴本地推广网站有哪些我所了解的网页制作软件
  • 深圳网站建设公司排名网站建设报告 商业价值
  • 成都网站设计公司排名企业建站框架
  • 外贸推广建站蓝颜seo牛win7做网站服务器
  • 做网站公司未来的发展方向前端网站开发项目经验
  • 网站建设打造手工活外发加工正规厂家直接发货
  • 网页设计作业之玩具商城网站外国购物网站有哪些平台
  • 网站开发用什么服务器重庆 手机网站制作
  • 做网站备案需要啥资料百度指数代表什么
  • 重庆建网站 私单石家庄工程大学
  • 建材公司网站建设案例网站 功能呢
  • 如何建一个手机网站推广app赚钱
  • 企业网站建设需要哪些费用永济做网站单价
  • 网站排版设计欣赏黑科技wifi蹭网神器