Does userscript support static methods (object oriented)?
It "works" for you only because it's compiled into ES5 or otherwise reorganized by the bundler. The code is invalid by itself: class
declarations are initialized in the order of their appearance in the source code as it's just a syntactic sugar for prototype assignments so you can use it only after it was declared. Move Foo.classMethod()
to the end.
@wOxxOm 说道: It "works" for you only because it's compiled into ES5 or otherwise reorganized by the bundler. The code is invalid by itself:
class
declarations are initialized in the order of their appearance in the source code as it's just a syntactic sugar for prototype assignments so you can use it only after it was declared. MoveFoo.classMethod()
to the end.
The problem has been solved. Thanks.
Does userscript support static methods (object oriented)?
The following code works in its own HTML, but it doesn't seem to work in userscript.
I googled for information about using object-oriented syntax in userscript. I didn't get anything. I just read the document and didn't find the answer.
Who knows what's going on ?