0

I have been struggling this error for a while now. I've tried multiple ways and none of them work. All I am trying to do is to get this simple component working. Someone help please. :)

<script>
const app = new Vue({
  el: "#main",
  data: function(){
          return {
          search: '',
          customers: [
            { id: '1', name: 'Something', },
            { id: '2', name: 'Something else', },
            { id: '3', name: 'Something random', },
            { id: '4', name: 'Something crazy', }
          ]};
  },
  computed:
  {
      filteredCustomers:function()
      {
         var self=this;
         return this.customers.filter(function(cust){return cust.name.toLowerCase().indexOf(self.search.toLowerCase())>=0;});
         //return this.customers;
      }
  }
  });
</script>
<template>
<div id="main">
Search: <input type="text" v-model="search"/>   
<div v-bind:v-for="customer in filteredCustomers">
 <span>{{customer.name}}</span>
</div>
</div>
</template>

7
  • Get it working how? How is anyone supposed to know how it should work? Commented Oct 22, 2019 at 18:40
  • I don't expect it to magically work. What I mean is it's not working on my end. I am trying to create a Search Filter. But the real issue has been the error. I am unsure how to resolve it. "Vue is not Defined". Commented Oct 22, 2019 at 18:44
  • Did you include Vue like so vuejs.org/v2/guide/…? Commented Oct 22, 2019 at 18:44
  • You probably havn't used the vue CDN link in the correct page. How are you injecting vue into your web app? Commented Oct 22, 2019 at 18:47
  • Just did now, throws me two errors. Uncaught TypeError: Cannot set property 'render' of undefined Cannot find element: #main Commented Oct 22, 2019 at 18:49

1 Answer 1

2

You should include the Vue library.
One way of doing so is including using <script> as described in Vue's documentation.

Sign up to request clarification or add additional context in comments.

1 Comment

This works but now I got two other errors to resolve. I may just post the other two errors on another post since it's a bit unrelated. Thank you for your help. :)

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.