使用多个指令为组件添加数据属性 [英] Use more than one directive to add data attributes to components

查看:13
本文介绍了使用多个指令为组件添加数据属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个指令,它们应该向组件添加数据属性以进行测试,但是,实际上只添加了其中一个指令.这两个组件是 Bootstrap-Vue 的 BFormInput 和 BButton.

我尝试删除除一个按钮之外的所有内容,但仍未添加指令,即

 <b 按钮变体=主要"@click="searchJobs"类=四舍五入-0"v-jobs-search-button-directive="{ id: 'search-button' }">搜索</b-按钮></b-input-group>

wrapper.html() 输出为:

 <b-input-group-stub tag="div" class="sm-2 mb-2 mt-2"><b-button-stub target="_self" event="点击"routertag="a"variant="secondary" type="button" tag="button" class="rounded-0">搜索</b-button-stub></b-input-group-stub>

但是,当我将输入表单留在原地而不是按钮时添加它,即

<b-表单输入v-jobs-search-input-directive="{ id: 'input-keyword' }"class="mr-2 rounded-0"placeholder="输入搜索词...":value="this.searchConfig.Keyword"@input="this.updateJobsSearchConfig"/></b-input-group>

wrapper.html() 输出为:

<b-input-group-stub tag="div" class="sm-2 mb-2 mt-2"><b-form-input-stub value="" placeholder=输入搜索词..." type="text" class="mr-2 rounded-0" data-jobs-search-input-id="input-keyword"></b-form-input>

这就是我添加指令的方式