Elementui dialogダイアログボックスでtreeコンポーネントを使用して、`this.$refs.tree.getCheckedKeys()はなぜ値を取得できないのですか?どうやって解決しますか?

4634 ワード

Elementui dialogダイアログボックスでtreeコンポーネントを使用して、`this.$refs.tree.getCheckedKeys()はなぜ値を取得できないのですか?どうやって解決しますか?大神を求めます!「TypeError:Cannot read property'getCheckedKeys'of undefined」
 <el-dialog title="    " :visible.sync="showRoleTreeDialog">
        <el-tree :data="roleTreeList" show-checkbox node-key="id" :props="{label: 'name'}"
                 :default-checked-keys="checkedRoleIds" style="border: 0">
        </el-tree>
        <div slot="footer" class="dialog-footer">
            <el-button @click="showRoleTreeDialog = false">   </el-button>
            <el-button type="primary" @click="doAuthorize">   </el-button>
        </div>
    </el-dialog>
        

devotion 5 2017-09-30質問1回答
採用済み
treeラベルにはrefプロパティがないためhis.$が見つかりません.refs.tree、ref=「tree」を追加するには、次のように変更します.
<el-tree 
ref="tree"
:data="roleTreeList" 
show-checkbox 
node-key="id" 
:props="{label: 'name'}"
:default-checked-keys="checkedRoleIds" style="border: 0">
 </el-tree>