1

hi im using vuejs and laravel this is my vuejs code

Vue.component('search_and_select',{
    template:
    '<div>'+
        '<slot :test_text="test_text" :update_test_text="update_test_text"></slot>

    '</div>',
    data:function(){
        return {
            test_text:null,
        }
    },
    methods: {
     update_test_text(value) {
       this.test_text = value
     }
   }
});

and this is html code

<search_and_select>
  <div slot-scope="{ test_text, update_test_text }">
    <input
      type="text"
      :value="test_text"
      @input="update_test_text($event.target.value)"
    >
  </div>
</search_and_select>

like this everything working so good so far .. but if i tried to include page like this ..

@include('treats.text_values') // laravel blade

and inside treats.text_values i did this ..

<input
  type="text"
  :value="test_text"
  @input="update_test_text($event.target.value)"
>

its not working so how can i access vuejs using include in laravel .. thanks a lot

3
  • 1
    you have to mount your compoent to any id of blade Commented Mar 12, 2020 at 10:37
  • 1
    What do you mean with not working? It seems to work on my side. Commented Mar 16, 2020 at 18:42
  • its not working if i inspect element i gat it like this <input type="text" :value="test_text" @input="update_test_text($event.target.value)" > and its should be like this <input type="text"> Commented Mar 17, 2020 at 9:32

1 Answer 1

1
+50

first of all as @Kamlesh Paul said be sure your component is between your id or el in your app probably its #app and second of all if you cp and paste your code you'r missed a "'" in your template it should be like this:

Vue.component('search_and_select',{
    template:
    '<div>'+
        '<slot :test_text="test_text" :update_test_text="update_test_text"></slot>' +

    '</div>',
    data:function(){
        return {
            test_text:null,
        }
    },
    methods: {
     update_test_text(value) {
       this.test_text = value
     }
   }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.