• Как перезаписать значения из дочернего компонента в родитель?

    @Now159 Автор вопроса
    может быть не одно из самых лучших решений, но рабочее

    дочерний:
    <div @click="choice(item)" v-for="item in items" :key="item.id">
    
    </div>

    data: () => ({
        show: false,
        amount: null,
        choiceUserColor: "",
        choiceUserImg: "",
        choiceUserNumder: 0,
    
      }),
      methods: {
         this.choiceUserColor = item.title
          this.choiceUserImg = item.img
          this.choiceUserNumder = item.number
          console.log(this.choiceUserColor, this.choiceUserImg, this.choiceUserNumder)
          this.$emit('choiceUser', [this.choiceUserColor, this.choiceUserImg, this.choiceUserNumder])
        },
        methodClose() {
          this.show = false
        }
    
      }


    Родитель:

    <modal-palette @choiceUser="adaa" :items="items" :name="name" ref="modal"/>


    data: () => ({
    UserColor: "Violet",
    UserImg: "/temp/card-bg-12.svg",
    UserNumder: 522,
    
    }),
    methods: {
    adaa(args) {
          this.args = args
          this.UserColor = this.args[0]
          this.UserImg = this.args[1]
          this.UserNumder = this.args[2]
          console.log(args)
    },
    openModal() {
    this.$refs.modal.show = true
    },
    }
    Ответ написан
    Комментировать
  • Как правильно составить этот код?

    @Now159 Автор вопроса
    Благодарен, то что я хотел - получил))))
    public function One() {
    $cars = (Car::all('name'));
    $items = $cars->unique('name');

    return response()->json([
    'items' => $items
    ]);
    Ответ написан
    Комментировать