Vue2学习(3)

子组件索引

尽管有 props 和 events,但是有时仍然需要在 JavaScript 中直接访问子组件。为此可以使用 ref 为子组件指定一个索引 ID。例如:

<div id="parent">
  <user-profile ref="profile"></user-profile>
</div>
var parent = new Vue({ el: '#parent' })
// 访问子组件
var child = parent.$refs.profile

refv-for 一起使用时,ref 是一个数组,包含相应的子组件。

字符串模板(string template)

原文地址:https://www.cnblogs.com/feiyu6/p/8231076.html