J
J
jeruthadam2017-08-17 01:51:30
Vue.js
jeruthadam, 2017-08-17 01:51:30

How to make the contents of a non-arrow function available in the template?

Hello. Faced a problem that I can not transfer value from normal function. How to do it?

data () {
    return {
      status: 'ss'
    }
  },
created () {
    function adBlockNotDetected() {
      console.log('AdBlock is not enabled')
      status = 'AdBlock is not enabled'
    }
  }

Console log works, but status does not.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Shashenkov, 2017-08-17
@jeruthadam

And what about the context?

created () {
     var _this=this
    function adBlockNotDetected() {
      console.log('AdBlock is not enabled')
      _this.status = 'AdBlock is not enabled'
    }
  }

A
Alexander, 2017-08-17
@boratsagdiev

I think we can start by calling the function. You can put it in methods and call it from created like this.adBlockNotDetected()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question