How do I use js code in vue template?

JS code in VUE template

Integrations

Hello,

Sorry, i have a very basic question. I try to use var elem = document.getElementById('para'); in my Vue template file in the <script lang="ts"> section, but i get an error message. How can i run own JS code in vue template?

Thx, 
Tamas

You can add it in the <script> tag, or in one of the vue lifecycle hooks.

I try to add

<script>
console.log("hello");
</script>

before <script lang="ts"> but not working.

When i add after, i get an error.
thx

try this

<script>
created() {
console.log('its working.. ');
}
<script>

dont forget to export default...

also, mounted is preferred to created

<script>
export default {
    mounted() {
        console.log('its working.. ');
    }
}
</script>

Issue appears when you try to delete or edit a reply
insufficient permissions as "member"
https://prnt.sc/sgfn96

Thank you! I tried, and working, but make error. https://snipboard.io/cNMB1E.jpg

share your code

9