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

荆州建设网站vuejs做视频网站

荆州建设网站,vuejs做视频网站,最新室内设计效果图,百度快照推广一年要多少钱一、Vue生命周期 Vue生命周期#xff1a;就是一个Vue实例从创建 到 销毁 的整个过程。 生命周期四个阶段#xff1a;① 创建 ② 挂载 ③ 更新 ④ 销毁 1.创建阶段#xff1a;创建响应式数据 2.挂载阶段#xff1a;渲染模板 3.更新阶段#xff1a;修改数据#xff0c;更…一、Vue生命周期 Vue生命周期就是一个Vue实例从创建 到 销毁 的整个过程。 生命周期四个阶段① 创建 ② 挂载 ③ 更新 ④ 销毁 1.创建阶段创建响应式数据 2.挂载阶段渲染模板 3.更新阶段修改数据更新视图 4.销毁阶段销毁Vue实例 二、Vue生命周期钩子 Vue生命周期过程中会自动运行一些函数被称为【生命周期钩子】→ 让开发者可以在【特定阶段】运行自己的代码 !DOCTYPE html html langen headmeta charsetUTF-8titleTitle/title /head div idapph3{{ title }}/h3divbutton clickcount---/buttonspan{{ count }}/spanbutton clickcount/button/div /div script srchttps://cdn.jsdelivr.net/npm/vue2/dist/vue.js/script scriptconst app new Vue({el: #app,data: {count: 100,title: 计数器},// 1. 创建阶段准备数据beforeCreate() {console.log(beforeCreate响应式数据准备好之前,this.count)},created() {console.log(beforeCreate响应式数据准备好之后,this.count)//this.数据名 请求回来的数据//可以开始发送初始化渲染的请求了},// 2. 挂载阶段渲染模板beforeMount() {console.log(beforeMount模版渲染之前,document.querySelector(h3).innerHTML)},mounted() {console.log(beforeMount模版渲染之前,document.querySelector(h3).innerHTML)},// 3. 更新阶段(修改数据 → 更新视图)beforeUpdate() {console.log(beforeUpdate)},updated() {console.log(Updated)},// 4. 卸载阶段beforeDestroy() {console.log(beforeDestroy)},destroyed() {console.log(destroyed)}}) /script /html三、生命周期钩子小案例 1、在created中发送数据 !DOCTYPE html html langen headmeta charsetUTF-8title头条/title /head style* {margin: 0;padding: 0;list-style: none;}.news {display: flex;height: 120px;width: 600px;margin: 0 auto;padding: 20px 0;cursor: pointer;}.news .left {flex: 1;display: flex;flex-direction: column;justify-content: space-between;padding-right: 10px;}.news .left .title {font-size: 20px;}.news .left .info {color: #999999;}.news .left .info span {margin-right: 20px;}.news .right {width: 160px;height: 120px;}.news .right img {width: 100%;height: 100%;object-fit: cover;} /stylediv idappulli classnews v-for(item,index) in list :keyitem.iddiv classleftdiv classtitle{{ item.title }}/divdiv classinfospan{{ item.source }}/spanspan{{item.time}}/span/div/divdiv classrightimg :srcitem.img alt/div/li/ul /div script srchttps://cdn.jsdelivr.net/npm/vue2/dist/vue.js/script script srchttps://cdn.jsdelivr.net/npm/axios/dist/axios.min.js/script script// 接口地址http://hmajax.itheima.net/api/news// 请求方式getconst app new Vue({el: #app,data: {list: []},async created(){const res await axios.get(http://hmajax.itheima.net/api/news)this.list res.data.data}}) /script/html2、在mounted中获取焦点 在进入页面时让输入框获取焦点 !DOCTYPE html html langen headmeta charsetUTF-8title搜索/title /head stylehtml,body {height: 100%;}.search-container {position: absolute;top: 30%;left: 50%;transform: translate(-50%, -50%);text-align: center;}.search-container .search-box {display: flex;}.search-container img {margin-bottom: 30px;}.search-container .search-box input {width: 512px;height: 16px;padding: 12px 16px;font-size: 16px;margin: 0;vertical-align: top;outline: 0;box-shadow: none;border-radius: 10px 0 0 10px;border: 2px solid #c4c7ce;background: #fff;color: #222;overflow: hidden;box-sizing: content-box;-webkit-tap-highlight-color: transparent;}.search-container .search-box button {cursor: pointer;width: 112px;height: 44px;line-height: 41px;line-height: 42px;background-color: #ad2a27;border-radius: 0 10px 10px 0;font-size: 17px;box-shadow: none;font-weight: 400;border: 0;outline: 0;letter-spacing: normal;color: white;}body {background: no-repeat center /cover;background-color: #edf0f5;} /stylediv classcontainer idappdiv classsearch-containerdiv classsearch-boxinput typetext v-modelwords idinpbutton搜索一下/button/div/div /divscript srchttps://cdn.jsdelivr.net/npm/vue2/dist/vue.js/script scriptconst app new Vue({el: #app,data: {words: },//核心思路等输入框出来让输入框获取焦点mounted() {document.querySelector(#inp).focus()}}) /script /html四、案例——记账清单 1、需求图示 2、需求分析 1.基本渲染 2.添加功能 3.删除功能 4.饼图渲染 3、思路分析 1.基本渲染 立刻发送请求获取数据 created拿到数据存到data的响应式数据中结合数据进行渲染 v-for消费统计 — 计算属性 2.添加功能 收集表单数据 v-model使用指令修饰符处理数据给添加按钮注册点击事件对输入的内容做非空判断发送请求请求成功后对文本框内容进行清空重新渲染列表 3.删除功能 注册点击事件获取当前行的id根据id发送删除请求需要重新渲染 4.饼图渲染 初始化一个饼图 echarts.init(dom) mounted钩子中渲染根据数据试试更新饼图 echarts.setOptions({…}) 4、实现 !DOCTYPE html html langen headmeta charsetUTF-8titleTitle/title /head !-- CSS only -- linkrelstylesheethrefhttps://cdn.jsdelivr.net/npm/bootstrap5.1.3/dist/css/bootstrap.min.css / style.red {color: red!important;}.search {width: 300px;margin: 20px 0;}.my-form {display: flex;margin: 20px 0;}.my-form input {flex: 1;margin-right: 20px;}.table :not(:first-child) {border-top: none;}.contain {display: flex;padding: 10px;}.list-box {flex: 1;padding: 0 30px;}.list-box a {text-decoration: none;}.echarts-box {width: 600px;height: 400px;padding: 30px;margin: 0 auto;border: 1px solid #ccc;}tfoot {font-weight: bold;}media screen and (max-width: 1000px) {.contain {flex-wrap: wrap;}.list-box {width: 100%;}.echarts-box {margin-top: 30px;}} /stylediv idappdiv classcontain!-- 左侧列表 --div classlist-box!-- 添加资产 --form classmy-forminput v-model.trimname typetext classform-control placeholder消费名称 /input v-model.numberprice typetext classform-control placeholder消费价格 /button clickadd typebutton classbtn btn-primary添加账单/button/formtable classtable table-hovertheadtrth编号/thth消费名称/thth消费价格/thth操作/th/tr/theadtbodytr v-for(item,index) in list :keyitem.idtd{{ index 1}}/tdtd{{ item.name }}/tdtd :class{ red: item.price 500}{{ item.price}}/tdtda clickdel(item.id) hrefjavascript:;删除/a/td/tr/tbodytfoottrtd colspan4消费总计 {{ totalPrice }}/td/tr/tfoot/table/div!-- 右侧图表 --div classecharts-box idmain/div/div /div script srchttps://cdn.jsdelivr.net/npm/echarts5.4.0/dist/echarts.min.js/script script srchttps://cdn.jsdelivr.net/npm/vue2/dist/vue.js/script script srchttps://cdn.jsdelivr.net/npm/axios/dist/axios.min.js/script script/*** 接口文档地址* https://www.apifox.cn/apidoc/shared-24459455-ebb1-4fdc-8df8-0aff8dc317a8/api-53371058** 功能需求* 1. 基本渲染** 2. 添加功能* 3. 删除功能* 4. 饼图渲染*/const app new Vue({el: #app,data: {list: [],name:,price:},computed: {totalPrice () {return this.list.reduce((sum, item) sum item.price,0 )}},created() {// const res await axios.get(https://applet-base-api-t.itheima.net/bill,{// params: {// creator: wangkay// }// })// this.list res.data.datathis.getList()},mounted() {this.myChart echarts.init(document.querySelector(#main))this.myChart.setOption ({tooltip: {trigger: item},legend: {top: 5%,left: center},series: [{name: 消费账单,type: pie,radius: [40%, 70%],avoidLabelOverlap: false,itemStyle: {borderRadius: 10,borderColor: #fff,borderWidth: 2},label: {show: false,position: center},emphasis: {label: {show: true,fontSize: 40,fontWeight: bold}},labelLine: {show: false},data: []}]});},methods:{async getList(){const res await axios.get(https://applet-base-api-t.itheima.net/bill,{params: {creator: wangkay}})this.list res.data.datathis.myChart.setOption({series: [{data: this.list.map(item ({value: item.price, name: item.name}))}]})},async add() {if (!this.name){alert(请输入名称)return}if (typeof this.price !number){alert(请输入正确的消费价格)return}const res await axios.post(https://applet-base-api-t.itheima.net/bill,{creator: wangkay,name: this.name,price: this.price})this.getList()this.namethis.price},async del(id) {const res await axios.delete(https://applet-base-api-t.itheima.net/bill/${id})this.getList()}}}) /script /html五、工程化开发和脚手架 1.开发Vue的两种方式 核心包传统开发模式基于html / css / js 文件直接引入核心包开发 Vue。工程化开发模式基于构建工具例如webpack的环境中开发Vue。 工程化开发模式优点 提高编码效率比如使用JS新语法、Less/Sass、Typescript等通过webpack都可以编译成浏览器识别的ES3/ES5/CSS等 工程化开发模式问题 webpack配置不简单雷同的基础配置缺乏统一的标准 为了解决以上问题所以我们需要一个工具生成标准化的配置 2.脚手架Vue CLI 基本介绍 Vue CLI 是Vue官方提供的一个全局命令工具 可以帮助我们快速创建一个开发Vue项目的标准化基础架子。【集成了webpack配置】 好处 开箱即用零配置内置babel等工具标准化的webpack配置 使用步骤 全局安装只需安装一次即可 yarn global add vue/cli 或者 npm i vue/cli -g查看vue/cli版本 vue --version创建项目架子vue create project-name(项目名不能使用中文)启动项目yarn serve 或者 npm run serve(命令不固定找package.json) 六、项目目录介绍和运行流程 1、项目目录介绍 虽然脚手架中的文件有很多目前咱们只需人事三个文件即可 main.js 入口文件App.vue App根组件index.html 模板文件 2、运行流程 七、组件化开发 ​ 组件化一个页面可以拆分成一个个组件每个组件有着自己独立的结构、样式、行为。 ​ 好处便于维护利于复用 → 提升开发效率。 ​ 组件分类普通组件、根组件。 ​ 比如下面这个页面可以把所有的代码都写在一个页面中但是这样显得代码比较混乱难易维护。咱们可以按模块进行组件划分 1、根组件App.vue 1.根组件介绍 整个应用最上层的组件包裹所有普通小组件 2.组件是由三部分构成 三部分构成 template结构 有且只能一个根元素script: js逻辑style 样式 (可支持less需要装包) 让组件支持less 1 style标签lang“less” 开启less功能 2 装包: yarn add less less-loader -D 或者npm i less less-loader -D 2、普通组件的注册使用-局部注册 1.特点 只能在注册的组件内使用 2.步骤 创建.vue文件三个组成部分在使用的组件内先导入再注册最后使用 3.使用方式 当成html标签使用即可 组件名/组件名 4.注意 组件名规范 — 大驼峰命名法 如 HmHeader 5.语法 // 导入需要注册的组件 import 组件对象 from .vue文件路径 import HmHeader from ./components/HmHeaderexport default { // 局部注册components: {组件名: 组件对象,HmHeader:HmHeaer,HmHeader} }3、普通组件的注册使用-全局注册 1.特点 全局注册的组件在项目的任何组件中都能使用 2.步骤 创建.vue组件三个组成部分main.js中进行全局注册 3.使用方式 当成HTML标签直接使用 组件名/组件名 4.注意 组件名规范 — 大驼峰命名法 如 HmHeader 5.语法 Vue.component(‘组件名’, 组件对象) 例 // 导入需要全局注册的组件 import HmButton from ./components/HmButton Vue.component(HmButton, HmButton)
http://www.w-s-a.com/news/154735/

相关文章:

  • 学院宣传网站建设简介做网站没灵感
  • 网站建设终稿确认书网站意义学校
  • 3小时网站建设平台专业制作教学课件
  • 曲阜网站建设百度开户现货黄金什么网站可以做直播
  • 比较好的企业建站平台小程序开发外包该注意些什么
  • 建行官网官网网站吗二次元风格wordpress模板
  • 怎样开通自己的网站网址导航哪个主页最好
  • 大良o2o网站建设详情页设计说明怎么写
  • 您与此网站之间建立的连接不安全汽车cms系统是什么意思
  • 有没有做logo的网站企业网站的内容营销
  • 哈尔滨做企业网站怎么做网站自动响应
  • 网站建设硬件和软件技术环境配置签约做网站模板
  • 教育网站建设的素材手机app制作流程
  • 免费行情软件网站大全下载网站备案查询
  • flex网站模板wordpress实时预览
  • 建设银行网站模板为什么企业要建设自己的企业文化
  • 网站建设必知免费手机网站建站系统
  • ssh可以做wap网站么嘉兴seo排名
  • 站内优化包括哪些帝国做企业网站
  • 做网站seo赚钱吗网络维护和故障维修
  • 企业网站可以自己做摄影网站开发背景怎么写
  • 网站百度指数seo最好的工具
  • 宝安专业网站建设推荐设计感强的网站
  • 网站建设 6万元北京知名的品牌设计公司
  • 网站建设的总体需求是什么vmware 下wordpress
  • 光谷网站建设请检查网络
  • 申请建设网站的报告书商务网站开发课程体会
  • 网站开发实训总结致谢群晖wordpress设置
  • 关于酒店网站建设的摘要天津市建设工程信息网官网首页
  • 网站alexa排名查询手机网站制作器