【问题标题】:inertia get clearing my search input type惯性得到清除我的搜索输入类型
【发布时间】:2021-07-19 01:34:16
【问题描述】:

我正在使用 laravel 惯性和 vuejs 为我的表格创建一个搜索框。我在 vue 的方法函数中使用 this.$inertia.get("/member", { term: this.term }); 时遇到问题,因为它会清除我的搜索框。当我尝试使用 this.$inertia.replace(this.route("member.index", { term: this.term })); 替换上面的代码时,它说替换已被贬值。

这是我的完整代码。

从我的搜索输入类型:

<input
    type="text"
    name="table_search"
    class="form-control float-right"
    placeholder="Search"
    v-model="term"
    @keyup="search"
/>

还有我的脚本:

export default {
  props: {
    members: Object,
    filters: Object,
  },

  data() {
    return {
      term: "",
    };
  },

  components: {
    AppLayout,
    Paginator,
  },

  methods: {
    search() {
      //   this.$inertia.replace(this.route("member.index", { term: this.term }));
      this.$inertia.get("/member", { term: this.term });
    },
  },
};
</script>

【问题讨论】:

    标签: vue.js search laravel-8 inertiajs


    【解决方案1】:

    尝试使用{ preserveState:true } 选项。

    你的代码会是这样的:

    this.$inertia.get("/member", { term: this.term }, { preserveState: true });
    

    请参阅文档here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-22
      • 1970-01-01
      • 2019-03-24
      • 1970-01-01
      • 2020-07-29
      • 1970-01-01
      • 1970-01-01
      • 2016-11-15
      相关资源
      最近更新 更多