vue中子元件的拆分 父元件與子元件之間的傳值
阿新 • • 發佈:2019-01-09
vue是元件式開發,儘量獨立出子元件
prop():父元件傳值給子元件
$emit():子元件傳值給父元件
子元件中的設定: 使用bind
<template> : default-checked = "check" @checked="getCurrent" </template> <script> export default { name: ' camelName ', //name命名採用駝峰式命名, 這裡name定義雖然和後面引用的子元件名沒有關係,但是儘量保持一 致 data () { return { ......... // 定義引數 }, } props: ['check'], created (){ .......// 生命週期函式,使用this初始化函式 }, method:{ ...... function getCurrent (param){</style>
父元件
</style>