beginners, using vue-cli to write the front end, because of the need for a side menu bar, found a very good template:
idebar-menu" rel=" nofollow noreferrer "> https://github.com/huang-x-h/.
this template is very simple, the home directory only has html files, a js file and a css file, and uses jquery at the same time.
it"s OK to open html, directly locally, but there"s a big problem with moving to a vue-cli project.
in the original html page:
js$.sidebarMenu($(".sidebar-menu"))
menu.vue:
I copied this sentence in mounted, and then transferred the contents of the js file to
in methods
(there is only one function in the js file $sidebarMenu
)
at this time .
error report:
Syntax Error: Unexpected token, expected,
, but this in itself is just unknown. So I changed the function name to $_ sidebarMenu
(both mounted
and methods
)
error report transferred to $_ sidebarMenu = function (menu) {
in the first sentence $_ sidebarMenu =
in methods
.
if you change this sentence to $_ sidebarMenu:function (menu) {
or $_ sidebarMenu (menu) {
, the error will disappear, but the template menu will not run correctly, and the runtime will report an error that is not defined by the function $_ sidebarMenu
.
I really don"t know how to deal with these problems:
1, why does the function name of $.sidebarMenu report an error? Is it not possible to define a function like
2, $_ sidebarMenu = function (menu)?
3, why did you finally report that the function is undefined?