search

Home  >  Q&A  >  body text

javascript - Where should vue2 public methods be written?

vue2 Where should public methods be written?

过去多啦不再A梦过去多啦不再A梦2748 days ago675

reply all(6)I'll reply

  • 黄舟

    黄舟2017-05-19 10:23:22

    Create a utils under lib, just import it when you want to use it

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-19 10:23:22

    Write a util.js and write the methods here. Be careful to expose it as a module. When using it, import it, and then you can use the methods inside

    reply
    0
  • 为情所困

    为情所困2017-05-19 10:23:22

    Write a separate JS file, and then expose the method. The VUE page refers to your JS file to call the exposed method

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-19 10:23:22

    You can also use mixins

    reply
    0
  • 迷茫

    迷茫2017-05-19 10:23:22

    Use vueX? Just write it in actions, so that it can be easily called in the component. If you write additional js, it will be troublesome to import every time

    reply
    0
  • 怪我咯

    怪我咯2017-05-19 10:23:22

    Public methods have nothing to do with vue instances

    reply
    0
  • Cancelreply