如何重置组件的初始数据

2022-05-05

以下示例是关于Html中包含如何重置组件的初始数据用法的示例代码,想了解如何重置组件的初始数据的具体用法?如何重置组件的初始数据怎么用?如何重置组件的初始数据使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。

文件名:app.vue[英]:How to reset a component’s initial data源码类型:Html
<script>
const initialState = () => {
  return {
    modalBodyDisplay: "getUserInput",
    submitButtonText: "Lookup",
    addressToConfirm: null,
    bestViewedByTheseBounds: null,
    location: {
      name: null,
    },
  };
};

export default {
  data() {
    return initialState();
  },

  methods: {
    reset() {
      Object.assign(this.$data, initialState());
    },
  },
};
</script>

本文地址:https://www.itbaoku.cn/snippets/785117.html