Issue
I am trying to build a mobile app with Svelte.js and Ionic v4.
1) I got the svelte-template.
2) Installed ionic with npm install @ionic/core@latest --save.
3) Installed postcss and imported @ionic css in global.css
Rollup is extracting the @ionic css but it seems that there maybe something wrong with the way it is doing. The ionic components are acessible, but I cannot see a thing. The css is not being applied properly.
Has anyone managed to make Svelte work with Ionic v4? Or at least, Ionic with some vanilla js?
Solution
I did. Using the CDN was easiest.
Scaffold a new app:
degit sveltejs/template myapp
Add CDN to public/index.html above the ./global.css
<!-- ionic -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css"/>
<!-- ionicons -->
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule="" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
- Update App.svelte
<script>
const greet = () => alert('hi')
</script>
<ion-app>
<ion-content>
<ion-header>
<ion-toolbar>
<ion-title>My App</ion-title>
</ion-toolbar>
</ion-header>
</ion-content>
<ion-footer>
<ion-button color="secondary" expand="block" on:click={greet}>
Greet
</ion-button>
</ion-footer>
</ion-app>
- Run
yarn && yarn dev
Answered By - deezy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.