【问题标题】:Passing options containing blank spaces from Laravel blade to Vue multiselect将包含空格的选项从 Laravel 刀片传递到 Vue 多选
【发布时间】:2021-07-21 17:13:19
【问题描述】:

我正在尝试在我的 Laravel 刀片文件中使用 Vue Multiselect。我将数据放入数组中并将其作为道具传递给选项。 When option is one word(ex. "View") everything is working.但是当该选项包含多个单词(例如“查看客户”)时,我收到以下错误:

当我打印 json 数组时,数据会按原样显示:

在我的刀片文件中:

<grouped-select :options={{json_encode($allOptions)}}></grouped-select>

Vue 分组多选:

<template>
  <div>
    <multiselect
      v-model="value"
      :options="options"
      :multiple="true"
      group-values="libs"
      group-label="language"
      :group-select="true"
      placeholder="Click to select"
      track-by="name"
      label="name"
      ><span slot="noResult"
        >Oops! No elements found. Consider changing the search query.</span
      ></multiselect
    >
  </div>
</template>

<script>
import Multiselect from "vue-multiselect";

export default {
  props: [JSON.parse("options")],
  components: {
    Multiselect,
  },
  data() {
    return {
      value: [],
    };
  },

任何想法是什么问题,我该如何解决?谢谢

【问题讨论】:

标签: php json laravel vue.js multi-select


【解决方案1】:

我解决了这个问题。如果有人有同样的问题,我只是添加了双引号

<grouped-select :options="{{json_encode($allOptions)}}"></grouped-select>

【讨论】:

    猜你喜欢
    • 2017-02-24
    • 2021-07-05
    • 2018-10-13
    • 2017-07-27
    • 2023-04-02
    • 2018-06-25
    • 2021-10-22
    • 2018-08-24
    • 2018-08-04
    相关资源
    最近更新 更多