Hi all, I'm trying using dashboard2 and I would understand where locate the external javascript scripts
for dashboard 1 I set httpstatic path in the setting file adding the folder where my script are located in "/static/" and I call them from ui with the following line
lets say you have an image.jpg in your static folder
you place the image in /home/pi/.node-red/html/ and
it should be served at https://localhost:1880/static/image.jpg
If you visit the link directly can you see the asset / script ?
when it comes to loading the asset from dashboard .. since the dashboard is served from /dashboard
im guessing you should go one level back ../ in order to access /static ?
example : <script src="../static/myScript.js"></script>
Do you have any errors in the browser console logs ?
It could be the case that the script doesnt load in time before the Dashboard 2 ui-template component runs its code. If thats the case see this post how a timer can be used to wait for the script to load (link)
many thanks for your help
no error appears in web page console
if I try adding
export default {
mounted() {
let interval = setInterval(() => {
if (window.jsqrscanner) {
clearInterval(interval);
// now it is loaded, we can initialise and use it
}
}, 100);
}
}
in the web console appears
index-CkQi99U4.js:236 errorCaptured SyntaxError: Unexpected token 'export'
at Proxy.created (index-CkQi99U4.js:236:6486)
at callWithErrorHandling (index-CkQi99U4.js:22:2165)
at callWithAsyncErrorHandling (index-CkQi99U4.js:22:2273)
at callWithAsyncErrorHandling (index-CkQi99U4.js:22:2412)
at callHook$1 (index-CkQi99U4.js:22:35193)
at applyOptions (index-CkQi99U4.js:22:34256)
at finishComponentSetup (index-CkQi99U4.js:22:72406)
at setupStatefulComponent (index-CkQi99U4.js:22:71538)
at setupComponent (index-CkQi99U4.js:22:70927)
at H (index-CkQi99U4.js:22:53467) Proxy(Object) {_: {…}, $socket: Socket, send: ƒ, submit: ƒ, …} https://vuejs.org/error-reference/#runtime-c