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

企业网站禁忌正规网站建设服务

企业网站禁忌,正规网站建设服务,wordpress 代码执行漏洞,作文网站投稿目录 一、组件基础 二、组件的嵌套关系 1. 基础架构 2. 嵌套 三、组件注册方式 1. 局部注册#xff1a; 2. 全局注册#xff1a; 四、组件传递数据 1. 基础架构 2. 传递多值 3. 动态传递数据 五、组件传递多种数据类型 1. Number 2. Array 3. Object 六、组…目录 一、组件基础 二、组件的嵌套关系 1. 基础架构 2. 嵌套  三、组件注册方式 1. 局部注册 2. 全局注册 四、组件传递数据 1. 基础架构 2. 传递多值 3.  动态传递数据 五、组件传递多种数据类型 1. Number 2. Array 3. Object 六、组件传递Props的校验 1. 默认值 2. 必选项 一、组件基础 组件最大的优势就是可复用性。 当使用构建步骤时我们一般将vue组件定义在一个单独的.vue文件当中这就被叫做单文件组织SFC 组件组成结构 ---- 在components文件当中新建文件MyApp.vue templatediv classcontainer{{ message }}/div /template scriptexport default{data(){return{message:组件基础组成}}} /script !-- 让当前样式只在当前组件中生效 如果不加scoped那么.container将会是全局样式在任何组件当中使用-- style scoped.container{font-size: 30px;color: red;} /style 组件引用结构-----在App.vue当中设置如下属性: script//第一步引入组件import MyApp from ./components/MyApp.vue;export default{//第二步注册组件components:{MyApp}} /script template!--第三步:显示组件--MyApp/ /template 二、组件的嵌套关系 组件允许我们将UI划分为独立的、可重用的部分并且可以对每个部分进行单独的思考。在实际应用中组件常常被组织成层层嵌套的树状结构 这和我们嵌套HTML元素的方式类似Vue实现了自己的组件模型使我们可以在每个组件内封装自定义内容与逻辑。 新建pages文件夹并创建以下文件‘ 1. 基础架构 Header.vue templateh3Header/h3 /template style scopedh3{width: 100%;height: 120px;border: 4px solid #333;text-align: center;line-height: 100px;box-sizing: border-box;} /style 在App.vue当中注册 scriptimport Header from ./components/Header.vue;export default{data(){},components:{Header}} /script templateHeader/ /template Main.vue: templatediv classmainh4Main/h4/div/templatestyle scoped.main{float: left;width: 60%;height: 400px;border: 4px solid #333;text-align: center;line-height: 100px;box-sizing: border-box;}.main h4{text-align: center;background-color: beige;} /style Aside.vue: templatediv classasideh4Aside/h4/div/templatestyle scoped .aside{float: right;width: 30%;height: 400px;border: 4px solid #333;text-align: center;line-height: 100px;box-sizing: border-box;} /style 2. 嵌套  新建Article.vue: templateh5Article/h5 /template styleh5{width:80%;margin:0 auto;text-align: center;line-height: 50px;box-sizing: border-box;margin-top: 20px;background:#999;} /style 在main.vue里引用article.vue templatediv classmainh4Main/h4Article/Article//div/template scriptimport Article from ./Article.vue;export default{components:{Article}} /script style scoped.main{float: left;width: 60%;height: 400px;border: 4px solid #333;text-align: center;line-height: 100px;box-sizing: border-box;}.main h4{text-align: center;background-color: beige;} /style 新建item.vue: templateh5Item/h5 /template style scopedh5{width:80%;margin: 0 auto;text-align: center;line-height: 100px;box-sizing: border-box;margin-top: 10px;background:#999;} /style 在aside.vue里引用item.vue: templatediv classasideh4Aside/h4Item/Item//div/template scriptimport Item from ./Item.vue;export default{components:{Item}} /script style scoped .aside{float: right;width: 30%;height: 400px;border: 4px solid #333;text-align: center;line-height: 100px;box-sizing: border-box;} /style 最终效果 三、组件注册方式 一个Vue组件在使用前需要先被“注册”这样Vue才能在渲染模板时找到其对应的实现。组件注册有两种方式全局注册和局部注册 1. 局部注册 前边讲的方案就是局部注册 2. 全局注册 我们这里使用Header.vue来进行全局注册 ①:那么首先在App.vue当中取消局部注册。 ②:在main.js当中设置全局注册方式 ③最终在哪里需要就在哪里引入 全局注册虽然很方便但有以下几个问题 1.全局注册但并没有被使用的组件无法在生产打包时被自动移除也叫“tree-shaking”)。如果你全局注册了一个组件即使它并没有被实际使用它仍然会出现在打包后的JS文件中         2.全局注册在大型项目中使项目的依赖关系变得不那么明确。在父组件中使用子组件时不太容易定位子组件的实现。和使用过多的全局变量一样这可能会影响应用长期的可维护性 局部注册需要使用components选项。 四、组件传递数据 组件与组件之间不是完全独立的而是有交集的那就是组件与组件之间是可以传递数据的传递数据的解决方案就是props 1. 基础架构 首先我们新建一个Parent.vue templateh3Parent/h3 /template scriptexport default{data(){return{}} } /script 其次我们再新建Child.vue templateh3Child/h3 /template scriptexport default{data(){return{}}} /script 我们让Parent.vue给Child.vue传值不过在此之前我们先让Parent成为Child的父组件。 2. 传递多值 也可以传递多个值   3.  动态传递数据 注意事项         props 传递数据只能从父级传递到子级不能反其道而行 五、组件传递多种数据类型 通过props传递数据不仅可以传递字符串类型的数据还可以是其他类型例如数字、对象、数组等。但实际上任何类型的值都可以作为props的值被传递。 1. Number parent.vue templateh3Parent/h3Child :titlemessage :ageage/Child /template scriptimport Child from ./Child.vueexport default{data(){return{message:我是动态的数据,age:20}},components:{Child}} /script Child.vue templateh3Child/h3p{{ title }}/pp{{ age }}/p /template scriptexport default{data(){return{}},props:[title,age]} /script 2. Array parent.vue: templateh3Parent/h3Child :titlemessage :ageage :namesnames/Child /template scriptimport Child from ./Child.vueexport default{data(){return{message:我是动态的数据,age:20,names:[张三,李四,王五]}},components:{Child}} /script child.vue: templateh3Child/h3p{{ title }}/pp{{ age }}/pulli v-for(item,index) of names :keyindex{{ item }}/li/ul /template scriptexport default{data(){return{}},props:[title,age,names]} /script 3. Object parent.vue: templateh3Parent/h3Child :titlemessage :ageage :namesnames :userInfouserInfo/Child /template scriptimport Child from ./Child.vueexport default{data(){return{message:我是动态的数据,age:20,names:[张三,李四,王五],userInfo:{name:admin,age:20}}},components:{Child}} /script child.vue: templateh3Child/h3p{{ title }}/pp{{ age }}/pulli v-for(item,index) of names :keyindex{{ item }}/li/ulp{{ userInfo.name }}/pp{{ userInfo.age }}/p /template scriptexport default{data(){return{}},props:[title,age,names,userInfo]} /script 六、组件传递Props的校验 Vue组件可以更细致地声明对传入的props的校验要求。 以下例子为接收  String  类型传输  number  控制台警告 script import ComponentB from ./ComponentB.vue; export default{data(){return{title:20}},components:{ComponentB} } /script style /style templateh3ComponentA/h3ComponentB :titletitle//template templateh3ComponentB/h3p{{ title }}/p /template script export default{data(){return{}},props:{title:{type:String}} } /script可以接收多种类型 props:{title:{type:[String,Number,Array,Object]} } 1. 默认值 模拟情况传递数据的时候并没有真实传递。 数字和字符串可以直接default但是如果是数组和对象必须通过工厂函数返回默认值。 templateh3ComponentA/h3ComponentB :titletitle :ageage :namesnames/ /templatescriptimport ComponentB from ./ComponentB.vue;export default{data(){return{title:测试,//age:20,//names:[Tom,Bob]}},components:{ComponentB} } /script ________________________________________________________________________________ templateh3ComponentB/h3p{{ title }}/pp{{ age }}/pulli v-for(name,index) of names :keyindex{{ name }}/li/ul /templatescript export default{data(){return{}},props:{title:{type:[String,Number,Array,Object]},age:{type:Number,default:0},//数字和字符串可以直接default但是如果是数组和对象必须通过工厂函数返回默认值names:{type:Array,default(){return [xxx]}}} } /script 2. 必选项 没有传值就会提示警告。 templateh3ComponentA/h3ComponentB :titletitle :ageage :namesnames/ /templatescriptimport ComponentB from ./ComponentB.vue;export default{data(){return{// title:测试,age:20,names:[Tom,Bob]}},components:{ComponentB} } /script templateh3ComponentB/h3p{{ title }}/pp{{ age }}/pulli v-for(name,index) of names :keyindex{{ name }}/li/ul /templatescript export default{data(){return{}},props:{title:{type:[String,Number,Array,Object],required:true},age:{type:Number,default:0},//数字和字符串可以直接default但是如果是数组和对象必须通过工厂函数返回默认值names:{type:Array,default(){return [xxx]}}} } /script 注意         props 是只读的不允许修改父元素传递过来的数据。 templateh3ComponentB/h3p{{ title }}/pp{{ age }}/pulli v-for(name,index) of names :keyindex{{ name }}/li/ulbutton clickupdateupdate/button /templatescript export default{data(){return{}},props:{title:{type:[String,Number,Array,Object],required:true},age:{type:Number,default:0},//数字和字符串可以直接default但是如果是数组和对象必须通过工厂函数返回默认值names:{type:Array,default(){return [xxx]}}},methods:{update(){console.log(this.title);this.title新数据}} } /script
http://www.dnsts.com.cn/news/147640.html

相关文章:

  • 青岛网站设计公司哪家好公司建设网站流程图
  • 做视频直播类型的网站带分销的小程序
  • wordpress 谷歌广告插件免费网站建设seo
  • 厦门网站建设 九来微信微官网开发
  • 网站群建设 公司企查查企业信息查询在线
  • 不用源码做网站搜索引擎入口大全
  • 重庆永川微网站建设大发快三网站自做
  • 网站备案网站要有内容吗成都华阳有没有做网站的
  • 网站怎么做舆情监测flash个人网站动画
  • 枣阳网站建设建材网站开发
  • 从零开始做一个网站需要多少钱wordpress 优化''
  • 怎么查询菠菜网站做没作弊成都网站建设网站建设
  • 有网站地图的网站工作证模板word
  • 做网站收费吗seo整站优化解决方案
  • 民族服装的网站建设小程序店铺怎么弄
  • 医院网站建设价格哈尔滨网站公司哪家好
  • 中山 做网站海外网站推广公司
  • 新浪做网站wordpress学院主题
  • 缙云建设局网站建筑工程网校排行榜
  • 上传文档到网站上怎么做北京建筑公司有哪些
  • 商务网站开发流程有三个阶段重庆制作网站首页
  • 国内高端品牌网站建设wordpress好还是dz好
  • 公司网站建设项目的成本计划广东省建设行业数据开放平台
  • 网站建设目标规划wordpress登录vip
  • 建设工程查询网站谷歌seo专员
  • wap建站教程东营新闻联播在线直播
  • 五金加工东莞网站建设集美网站建设
  • 网站排名优化软件有哪些外包公司的优势和劣势
  • 西安做网站电话国际大型门户网站
  • 深圳门户网站建设方案宣讲家网站 家风建设