Comments (7)
@CaptainYouz This happens because the ES6/2015 arrow function syntax (() => {}
) binds this
to the parent context. In this case, the parent context is the module. Since this
is undefined in the module context, that undefined value is passed to each of the lifecycle methods instead of the view model as you'd expect.
To fix this, you'll need to use a normal function declaration:
created: function () {
console.log('created', this);
},
Or, my personal preference is the ES6/2015 shorthand, which does the same as above:
created () {
console.log('created', this);
},
from browserify-simple.
@theluk You don't need to do anything special. Just wrapping the function with debounce should work, e.g.:
myMethod: debounce(
function () {
// `this` is the app/component instance here
},
500
)
from browserify-simple.
Thanks for the explanation !
It's working now ๐ .
from browserify-simple.
great!
from browserify-simple.
but this
is still link methods.but not vm.
from browserify-simple.
Thanks a lot!!!
from browserify-simple.
how are you dealing with methods you need to bind to this
. for example when you want to wrap a method in lodashยดs debounce?
from browserify-simple.
Related Issues (13)
- Import component is not working HOT 7
- I need vue+vue-route+vuex HOT 1
- Not compiling SASS in .vue files HOT 7
- Initiating in current directory instructions HOT 1
- Uses runtime-only build of Vue, even though webpack-simple uses the full version by default HOT 2
- npm run dev issue.
- How to support multi browserify bundles? HOT 1
- Does it recommend using vue with browserify now? HOT 2
- dev server doesn't work
- Syntax Error creating project HOT 1
- Template appears broken HOT 3
- No matches found. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browserify-simple.