-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Split JS code from HTML #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Put the code in a .js file (say login.js), then replace your script tag with |
@AgentEpsilon isn't there a way like putting both: Login.html and Login.js in same path and let Svelte handle? |
I'd look in to setting up some sort of bundler such as Webpack, Browserify, or Rollup. |
See #65 |
Will close this as it's a dupe of #65 – this isn't currently supported. @EchoNox when you're including code samples in comments, there's a way to render them as code blocks – use ``` (three backticks) optionally followed by a language id like <input type='email' bind:value='email' /> <input type='password' bind:value='password' />
<button on:click='login()'>Click Me</button>
<script>
export default {
data () {
return {
email: '', password: ''
}
}
methods: {
login () {
console.log(email, password);
}
}
};
</script> |
@Rich-Harris ok thanks I used the code button but it didn't transform sorry |
Yep, the code button is for inline code, not for blocks of code |
Uh oh!
There was an error while loading. Please reload this page.
Just a question. As the title says how can I split the js code from the html file? so:
`
<script> export default { data () { return { email: '', password: '' } } methods: { login () { console.log(email, password); } } }; </script>`Click Me
How can I have the js code in a seperate js file?
The text was updated successfully, but these errors were encountered: