1、当选择全部时,后端返回的typeid为 -1
2、前端html和js代码如下:
- <label style="padding-left:10px;">按类型:label>
- <el-select @change="selectChange" v-model="typeid" placeholder="请选择">
- <el-option
- v-for="item in typeList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- el-option>
- el-select>
- <script type="text/javascript">
- var total = new Vue({
- el: '#total',
- data: function() {
- return {
- typeList: [{
- id: '-1',
- name: '全部'
- }],
- typeid: -1
- }
- },
- });
- script>
修改data里的id为数字-1,正确代码如下: