10.vue指令6 内容指令-v-on-调用传参作用传自定义参数步骤第一步在第一个加入形参如price随后在函数中加入参数methods:{buy (price){this.monney -price}}加入标签属性在函数buy里加入参数button clickbuy(10)阿萨姆/button加入被执行标签div idapp button clickbuy(10)阿萨姆/button button clickbuy(5)ad钙奶/button p银行卡余额 {{money}}元/p /div补充添加边框1.手动添加syle属性!DOCTYPE html html langen head meta charsetUTF-8 meta http-equivX-UA-Compatible contentIEedge meta nameviewport contentwidthdevice-width, initial-scale1.0 titleDocument/title style .box { border: 3px solid #333; /* 黑色实线边框粗细 3px */ padding: 20px; /* 内边距让文字不贴边 */ border-radius: 12px; /* 圆角更美观 */ display: inline-block; /* 宽度根据内容自适应 */ background-color: #f5f5f5; /* 浅灰色背景突出显示 */ } button { margin: 5px; padding: 6px 14px; cursor: pointer; } p { font-size: 18px; font-weight: bold; } /style /head /head2.添加盒子div classbox效果代码!DOCTYPE html html langen head meta charsetUTF-8 meta http-equivX-UA-Compatible contentIEedge meta nameviewport contentwidthdevice-width, initial-scale1.0 titleDocument/title style .box { border: 3px solid #333; /* 黑色实线边框粗细 3px */ padding: 20px; /* 内边距让文字不贴边 */ border-radius: 12px; /* 圆角更美观 */ display: inline-block; /* 宽度根据内容自适应 */ background-color: #f5f5f5; /* 浅灰色背景突出显示 */ } button { margin: 5px; padding: 6px 14px; cursor: pointer; } p { font-size: 18px; font-weight: bold; } /style /head /head body !-- 创建 -- div idapp div classbox h3小杜自动售货机/h3 button clickbuy(10)阿萨姆/button button clickbuy(5)ad钙奶/button /div p银行卡余额 {{money}}元/p /div script srchttps://cdn.jsdelivr.net/npm/vue2/dist/vue.js/script script const app new Vue({ el: #app, data: { money: 100 }, methods:{buy (price){ this.money - price}} }); /script /body /html注意小心标签格式正确使用标签开div闭/div否则无法使用如下正确数种

相关新闻

最新新闻

案例分享| Latitude AI × Parasoft:搭建 L2-L3 自动驾驶量产验证与功能安全完整链路

案例分享| Latitude AI × Parasoft:搭建 L2-L3 自动驾驶量产验证与功能安全完整链路

搭建 L2-L3 自动驾驶量产验证与功能安全完整链路Latitude AI * Parasoft 本期导语 伴随 L2 至 L3 级 ADAS 大规模量产落地,自动驾驶软件多层架构协同迭代、多车型跨平台复用、ISO 26262 功能安全审计等多重压力叠加,大量车企面临测试资产迁移成本高、覆…

2026/8/15 10:07:37
魔兽争霸III老版本总闪退卡顿怎么办?WarcraftHelper兼容性修复全流程实战

魔兽争霸III老版本总闪退卡顿怎么办?WarcraftHelper兼容性修复全流程实战

魔兽争霸III老版本总闪退卡顿怎么办?WarcraftHelper兼容性修复全流程实战 【免费下载链接】WarcraftHelper Warcraft III Helper , support 1.20e, 1.24e, 1.26a, 1.27a, 1.27b 项目地址: https://gitcode.com/gh_mirrors/wa/WarcraftHelper 深夜十一点&…

2026/8/15 10:07:37
Windows 启动 Prometheus 并且监控本地cpu等资源的完整保姆级步骤!!!

Windows 启动 Prometheus 并且监控本地cpu等资源的完整保姆级步骤!!!

Windows 启动 Prometheus 完整步骤 前提:已经解压好 prometheus‑3.13.0‑windows‑amd64.zip,不要放在中文路径! ❌错误:D:\软件\普罗米修斯 ✅正确:D:\dev\prometheus 1. 目录结构 D:\dev\prometheus ├─ promethe…

2026/8/15 10:07:37
快速搞定Windows任务栏透明:TranslucentTB上手全攻略

快速搞定Windows任务栏透明:TranslucentTB上手全攻略

快速搞定Windows任务栏透明:TranslucentTB上手全攻略 【免费下载链接】TranslucentTB A lightweight utility that makes the Windows taskbar translucent/transparent. 项目地址: https://gitcode.com/gh_mirrors/tr/TranslucentTB 你有没有过这样的时刻&a…

2026/8/15 10:07:37
小米-米家,创建项目,实现第三方平台可以在米家中使用(四)

小米-米家,创建项目,实现第三方平台可以在米家中使用(四)

1,现在开始正式创建项目 使用 git clone https://github.com/MiEcosystem/miot-plugin-sdk.git 2,进行拉取项目,完成之后进入miot-plugin-sdk目录,在这个目录下选择合适的SDK进行切换,我使用的是SDK_10115&#xff0…

2026/8/15 10:07:37
TypeScript总结:16、面向对象速查

TypeScript总结:16、面向对象速查

面向对象速查 TypeScript 面向对象部分可以归纳为四个关键词:类、封装、继承和抽象。接口与泛型则进一步帮助我们描述结构和复用类型逻辑。 一、类的基本模板 class Person {name: string;age: number;constructor(name: string, age: number) {this.name name;thi…

2026/8/15 10:02:36