首先写一个扩展 ,头部标签

然后再script中声明一个对象,对象中有一个模板

需要挂载扩展,然后磁能生效

propsData 主要用于传值,在扩展里需要接收,需用 props接收

具体代码如下:

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>propsData option</title>
<script src="../assets/js/vue.js"></script>
</head>

<body>
<h1>propsData option</h1>
<hr>
<header></header>

<script>
var header_a = Vue.extend({
template: `<p>{{ message }}-{{ a }}</p>`,
data() {
return {
message: 'hello'
}
},
props: ['a']
})

new header_a({ propsData: { a: 12 } }).$mount('header')
</script>
</body>

</html>
 
vue.js基础__ propsData 选项

 

相关文章:

  • 2021-05-27
  • 2021-12-23
  • 2022-12-23
  • 2021-07-26
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2022-02-24
  • 2022-12-23
  • 2021-09-04
相关资源
相似解决方案