Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter bootstrap $refs在vue/引导vue更新后不再注册_Twitter Bootstrap_Vue.js_Popover_Bootstrap Vue - Fatal编程技术网

Twitter bootstrap $refs在vue/引导vue更新后不再注册

Twitter bootstrap $refs在vue/引导vue更新后不再注册,twitter-bootstrap,vue.js,popover,bootstrap-vue,Twitter Bootstrap,Vue.js,Popover,Bootstrap Vue,我在我的laravel项目中更新了bootstrap vue,并注意到以前有效的功能现在已经失效。代码保持不变,所以这是我唯一能想到的 我现在在vue@2.5.16和引导-vue@2.17.3 问题在于其中一个$ref未注册 该项目是旧的,我不是原作者。我对vue也相对缺乏经验,所以我不知道自从最初编写这段代码以来,vue和引导vue发生了什么变化 问题在于包装输入的组件 <b-container class="bv-example-row persons-second-part

我在我的laravel项目中更新了bootstrap vue,并注意到以前有效的功能现在已经失效。代码保持不变,所以这是我唯一能想到的

我现在在vue@2.5.16和引导-vue@2.17.3

问题在于其中一个$ref未注册

该项目是旧的,我不是原作者。我对vue也相对缺乏经验,所以我不知道自从最初编写这段代码以来,vue和引导vue发生了什么变化

问题在于包装输入的组件

<b-container class="bv-example-row persons-second-part">
    <b-row class="">
        <b-col class="person" sm="2" v-for="(person, index) in persons" @click.prevent="doubleClick(person, index)" :key="index">
            <div v-show="person.deleted === false">
                <div v-show="(currentState === 2 || currentState === 3)" v-dragged="onDragged" :id="getId(index)" style="z-index: 999" class="jag-i-centrum-label-upper-left drag-me" v-text="person.name">
                </div>
            </div>
            <b-popover :target="getId(index)" triggers="focus" placement="top">
                <input v-model="person.comment" ref="popoverInput" placeholder="Skriv beskrivning">
            </b-popover>
        </b-col>
    </b-row>
</b-container>
正在注册文件中的其他引用。我假设这不是因为在创建$refs时输入元素没有添加到DOM中。我认为这个假设正确吗

为什么它以前能工作?我怎样才能让它再次工作?
我很乐意提供更多细节,代码

弹出窗口和工具提示在
2.0.0
版本中重新编写完成,如果这是一个从
rc-*
版本升级的项目,这可能就是它停止工作的原因

在打开popover之后,您似乎正在使用ref来聚焦输入

支持安装组件时聚焦输入的
自动聚焦
道具。由于
惰性的
,因此只有在显示popover时才会安装它


问题不在于代码本身,而在于环境本身

npm安装vue@2.6
npm安装vue模板-compiler@2.6

然后,所有的原始代码再次工作

我确实从使用
setTimeout()
改为使用
Vue.nextTick
,因为我觉得这是比等待任意时间更好的解决方案

openPopup(person, index) {
      person.showContainer = !person.showContainer;
      let that = this;
      Vue.nextTick()
      .then(function () {
        const ref = that.getId(index);
        that.$root.$emit("bv::show::popover", ref);
        that.$refs.popoverInput[index].focus();
      })  
    },

以前,当我尝试打开popover时,我遇到了错误:
uncaughttypeerror:无法读取未定义的属性“0”
当我进行建议的更改时,我什么也得不到。由于您正在使用
getId(index)
,设置
id
目标,popover仍然没有打开。您不也应该在这里使用它吗
that.$root.$emit(“bv::show::popover”,“popover-”+index),以定义应显示哪个popover?此外,当您尝试显示popover时,popover目标是否可见?我在
openPopup()
setTimeout()
函数中有它,我尝试删除setTimeout,并尝试设置常规ID以进行测试,但仍然无法让它们再次显示您有
const ref=that.getId(index),但
ref
未在任何地方使用。这就是我提到它的原因。您还可以尝试增加超时时间,以查看是否存在计时问题。刚刚注意到您也在使用旧版本的Vue。当您在
2.5
I上升级到时,需要Vue
2.6
vue@2.6.12现在至少我有了流行天鹅绒。谢谢我希望我能从这里解决剩下的问题
openPopup(person, index) {
      person.showContainer = !person.showContainer;
      let that = this;
      Vue.nextTick()
      .then(function () {
        const ref = that.getId(index);
        that.$root.$emit("bv::show::popover", ref);
        that.$refs.popoverInput[index].focus();
      })  
    },