在使用官方select组件时,浏览器报错:vue.esm.js:558 [Vue warn]: You may have an infinite update loop in a component render function.(found in <ISelect>) 如下图:
select报错.png
多次查看vue 代码发现也没有问题 代码如下:

<template>
    <Select v-model="model2" style="width:200px">
        <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
    </Select>
</template>
<script>
    export default {
        data () {
            return {
                cityList: [
                    {
                        value: 'New York',
                        label: 'New York'
                    },
                    {
                        value: 'London',
                        label: 'London'
                    }
                ],
                model2: ''
            }
        }
    }
</script>

经过多次查询资料应该是vue和vue-template-compiler版本过低导致

"vue": "^2.2.6",
"vue-template-compiler": "^2.2.6",

升级vue和vue-template-compiler到2.5.2,在package.json直接修改

"vue": "^2.5.2",
"vue-template-compiler": "^2.5.2",

npm install

select没错.png

Last modification:August 8th, 2020 at 11:19 am
如果觉得我的文章对你有用,请随意赞赏