Vue用props
发布时间
阅读量:
阅读量
父传子props驼峰标识
当props中的变量采用驼峰命名方式时:
在组件调用过程中,需将大写字母转换为对应的小写字母,并在其前添加-符号,以此进行命名转换
例如:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>组件的构建</title>
</head>
<!--组件是单独封装的模块,拥有自己的data html模块-->
<!--组件中不可以访问vue实例中的data数据,不建议在里面访问vue实例对象-->
<!--组件中data中的数据必须以方法函数的方式返回数据,好处是函数可以直接返回一个对象,每一次返回数据对象都不一样,这样可以让数据不受影响-->
<body>
<div id="app2">
<cpn v-bind:title-msg-title = "tmsg" :st="str"></cpn>
<cpn v-bind:title-msg-title = "tmsg" :st="str" :t2 ='t2msg'></cpn>
</div>
<!--方法一写在script里面-->
全部评论 (0)
还没有任何评论哟~
