A
A
Alixx2019-12-18 21:31:02
Vue.js
Alixx, 2019-12-18 21:31:02

Error with Vue. How to run js scripts?

Hello!
(for some reason, the first time I couldn’t post the whole question, only a part was displayed)
I started using Webpack, Vue, Node.js for the first time (for me it’s a dense forest, I set it up for writing a chat), before that all js scripts are connected in templates blade via the script tag.
Run npm run dev in the project console. Further added

<example-component></example-component>
<script src="{{ asset('js/app.js') }}"></script>

to your pages. ExampleComponent.vue, js/app.js, js/bootstrap.js webpack.mix.js did not change in any way.
The vue component is displayed on the pages, but now no other js scripts connected in the blade templates (neither external nor internal) work. The console writes an error:
[Vue warn]: Error compiling template:
Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <script>, as they will not be parsed.

//   здесь красным пишет весь код моего скрипта, который подключен на странице

(found in <Root>)

Tell me why my js scripts are not even loaded with the page, but only app.js is loaded? How to "force" them to boot again?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alixx, 2019-12-18
@alixx

<div id="app"> </div>was a child of the body element and already contained all the rest of the content, incl. my js scripts.
I moved all js scripts outside of this container. And all the scripts are working.

K
Konstantin B., 2019-12-18
@Kostik_1993

Did you connect your component at least?)
5dfa72d969f18056379723.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question