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

深圳网站建设认准乐云电商网站建设收费

深圳网站建设认准乐云,电商网站建设收费,大良建网站,最优秀的佛山网站建设往期内容 《Vue零基础入门教程》第六课:基本选项 《Vue零基础入门教程》第八课:模板语法 《Vue零基础入门教程》第九课:插值语法细节 《Vue零基础入门教程》第十课:属性绑定指令 《Vue零基础入门教程》第十一课:事…

 往期内容

《Vue零基础入门教程》第六课:基本选项

《Vue零基础入门教程》第八课:模板语法

《Vue零基础入门教程》第九课:插值语法细节

《Vue零基础入门教程》第十课:属性绑定指令

《Vue零基础入门教程》第十一课:事件绑定指令

《Vue零基础入门教程》第十二课:双向绑定指令

《Vue零基础入门教程》第十三课:条件渲染

《Vue零基础入门教程》第十四课:列表渲染

1) 什么是样式绑定

通过绑定class属性 或者 style属性 修改样式

2) 绑定class属性

常见有两种语法

  • 数组写法
  • 对象写法

示例

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><script src="../node_modules/vue/dist/vue.global.js"></script><style>.red {color: red;}.blue {color: skyblue;}</style></head><body><div id="app"><!-- 原生的写法 --><span class="red blue">一段文字</span><!-- 绑定class属性 -- 对象的写法 --><span :class="obj">对象的写法</span><!-- 绑定class属性 -- 数组的写法(推荐) --><span :class="arr">数组的写法</span><span :class="foo">绑定一个变量</span><span :class="flag ? 'red' : 'blue'">使用表达式</span></div><script>const { createApp } = Vueconst vm = createApp({data() {return {obj: {red: true,blue: true,},arr: ['red', 'blue'],foo: 'red',flag: true,}},}).mount('#app')</script></body>
</html>

3) 绑定style属性

对象写法

示例

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><script src="../node_modules/vue/dist/vue.global.js"></script></head><body><div id="app"><!-- 原生的写法 --><div style="font-size: 32px; color: red">原生的写法</div><!-- 绑定style属性 -- 对象写法 --><div :style="obj">对象的写法</div></div><script>const { createApp } = Vueconst vm = createApp({data() {return {obj: {// 'font-size': '32px',fontSize: '32px',color: 'red',},}},}).mount('#app')</script></body>
</html>

4) 作业
💡 需求
实现京东tab栏切换

GIF.gif

参考答案

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><!-- 1.1 引入vue.js --><script src="../node_modules/vue/dist/vue.global.js"></script><!-- 2.2 实例静态页面(CSS部分) --><style>* {margin: 0;padding: 0;}li {list-style: none;}.menu-tab {display: flex;justify-content: space-between;margin: 50px auto;height: 40px;width: 700px;border: 1px solid #eee;border-bottom: 1px solid #e4393c;background-color: #f7f7f7;box-sizing: border-box;}.menu-tab .menu-item {flex: 1;display: flex;justify-content: center;align-items: center;font-size: 14px;color: #666;cursor: pointer;}.menu-tab .menu-item:hover {color: #e4393c;}.menu-tab .menu-item.current {color: #fff;background-color: #e4393c;}</style></head><body><!-- 1.2 编写页面容器 --><div id="app"><!-- 2.1 实例静态页面(HTML部分) --><ul class="menu-tab"><!-- <liv-for="(item, index) in items"class="menu-item":class="index == active ? 'current' : '' "@click="active = index"> --><liv-for="(item, index) in items"class="menu-item":class="index == active ? 'current' : '' "@click="handleClick(index)">{{item}}</li></ul></div><!-- 1.3 创建vue实例对象 --><script>const { createApp } = Vueconst vm = createApp({data() {return {items: ['商品介绍', '规格与包装', '售后保障', '商品评价(2000+)', '手机社区'],active: 0,}},methods: {handleClick(i) {console.log(i)this.active = i},},}).mount('#app')</script></body>
</html>

http://www.yayakq.cn/news/571358/

相关文章:

  • 织梦做的网站图片显示不了项目管理app
  • 群晖个人网站建设建设大型网站的公司
  • 桐乡市建设局官方网站中国机械网站
  • 响应式网站和自适应网站的区别成都网页制作培训机构
  • 网站建设需要什么硬件和软件wordpress 没有留言功能
  • 网站建设入门教程域名免费注册网站
  • 聊城做网站的公司精英网站权重最高是多少
  • html模板网站推荐如何将软件上传到公开网站
  • 代做网站关键词排名网站设计的原则不包括
  • 魏公村网站建设建设网络良好生态发挥网络的作用
  • 柳州网站优化天津设计师网站大全
  • 网站建设扌金手指六六国内企业手机网站建设
  • 网站建设与管理维护 李建青云服务器 部署网站
  • 长春火车站电话人工服务wordpress 虎嗅网
  • 做网站改变图片位置一个网站的建立需要什么
  • 网站管理规定网站域名到期什么意思
  • 洛阳网站设计哪家便宜浏阳做网站推荐
  • 揭阳企业网站建设公司建站平台哪个好
  • 中小企业做网站推广加盟项目
  • 个人网站 免费深圳网站建设艺之都
  • 青羊区城乡建设网站广州网站建设培训学校
  • 集团企业网站设计方案wordpress文章索引
  • 东莞哪些网络公司做网站比较好微信小程序商城怎么开通
  • 30几岁的人想学做网站北京十大app开发公司排名
  • php直播网站开发融资平台公司定义
  • 服装网站建设与实现手机门户网站建设方案
  • 新都有没有做网站的wordpress 全部设置
  • 电商网站设计规划书wordpress要多大空间
  • 昆明做网站建设多少钱无锡 网站 seo 优化
  • 经典网站源码wordpress网页设计步骤