[Vuejs]-Vue.js and javascript wont work

0👍

  1. Don’t name the created function the same as the vuejs lifecycle function.
  2. No need to declare it outside of your export, place it in methods, like this:

    methods: {
    init: function() {
    //code goes here
    }
    }

  3. document.getElementsByClassName does not return an instance of a node and therefore you can’t set the style this way. You would have to loop all elements first.
  4. You could just define the style as an object in your data function and bind it to the element with :style="someStyleObject"
  5. You can’t define mode in data if it’s also a property.
  6. Check your console, you’re going to have errors.

Leave a comment