vue报错data functions should return an object:

img


<script>
import { Getzhuanli } from "@/api/api.js";
export default {
  data() {
    return {
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10,
      },
      total: 0,
      data: [],
      dialogVisible: false,
      form: {},
    };
  },
  created() {
    this.getPractical();
  },
  methods: {
    getPractical() {
      Getzhuanli({ type: "发明专利" })
        .then((res) => {
          this.getList(res);
        })
        .catch((error) => {
          this.$message.error(error);
        });
    },
    getList(res) {
      // es6过滤得到满足搜索条件的展示数据list
      let list = res.filter(
        (item, index) =>
          item.ApplicationID.includes(this.queryInfo.query) ||
          item.Name.includes(this.queryInfo.query) ||
          item.Type.includes(this.queryInfo.query) ||
          item.Designer.includes(this.queryInfo.query)
      );
      console.log(list);
      this.data = list.filter(
        (item, index) =>
          index < this.queryInfo.pagenum * this.queryInfo.pagesize &&
          index >= this.queryInfo.pagesize * (this.queryInfo.pagenum - 1)
      );
      this.total = list.length;
    },
    // 搜索过滤数据
    search() {
      this.queryInfo.pagenum = 1;
      this.getList();
    },
    handleSizeChange(newSize) {
      this.queryInfo.pagesize = newSize;
      this.queryInfo.pagenum = 1;
      this.getList();
    },
    handleCurrentChange(newPage) {
      this.queryInfo.pagenum = newPage;
      this.getList();
    },
    open(row) {
      this.form = row;
      this.dialogVisible = true;
    },
  },
};
</script>

网上搜的都是data要有返回值,但是我写了呀。

问题不在这个vue组件,这个提示意思是data需要return,即下方所示代码

<script>
export default {
  data() {
    return {
      userInfo: {}
    }
  },

}
</script>

应该这个问题吧,element message 这样传值应该是string或者number

img

data functions should return an object: ----------- 数据函数应该返回一个对象:

img

这个函数要有返回值吧