এই ফিচারটি আপনাকে .md ফাইলে <style>, <script>, <script module>, #if, #each, #await, @html, @const, <svelte:xxx> লিখতে দেয়।

প্রাথমিক

এখানে একটি #if, #each, #await, @html, @const এর প্রাথমিক উদাহরণ

  • ${$.escape(str)}

Pass

Fail

Loading

${$.escape(res)}

${$.html("

Content render with @html

")}
<script>
  const items = ['foo', 'bar', 'zoo']
  let boolVal = $state(false)

  const promisePass = () => new Promise(resolve => {
    setTimeout(() => {
      resolve('Promise Passed!')
    }, 2000)
  })

  const promiseFail = () => new Promise((_, reject) => {
    setTimeout(() => {
      reject('Promise Failed!')
    }, 2000)
  })

  let promise = $derived(boolVal ? promisePass() : promiseFail())
</script>

<ul>
{#each items as item, i}
{@const str = `${i + 1}: ${item}`}
  <li>
    {str}
  </li>
{/each}
</ul>

<button onclick="{() => boolVal = !boolVal}">
Toggle
</button>

{#if boolVal}
  <h3 class="text-green">
    Pass
  </h3>
{:else}
  <h3 class="text-red">
    Fail
  </h3>
{/if}

{#await promise}
  <h3 class="text-orange">
    Loading
  </h3>
{:then res}
  <h3 class="text-green">
    {res}
  </h3>
{:catch err}
  <h3 class="text-red">
    {err}
  </h3>
{/await}

{@html "<h1>Content render with @html</h1>"}
md
Expand code
Syntax এর বিধিনিষেধ

মার্কডাউন ফাইলে সর্বদা উদ্ধৃতি ব্যবহার করুন।

-
+
<script>
  let let count: numbercount = 
function $state<0>(initial: 0): 0 (+1 overload)
namespace $state

Declares reactive state.

Example:

let count = $state(0);
@seehttps://svelte.dev/docs/svelte/$state Documentation@paraminitial The initial value
$
function $state<0>(initial: 0): 0 (+1 overload)
namespace $state

Declares reactive state.

Example:

let count = $state(0);
@seehttps://svelte.dev/docs/svelte/$state Documentation@paraminitial The initial value
state
(0)
</script> <button onclick: () => numberonclick={() => let count: numbercount++}></button> <button onclick: () => numberonclick={() => let count: numbercount++}></button>
svelte

একটি কাউন্টার

একটি কাউন্টার

> A counter
<script>
  let count = $state(0)
</script>

<button onclick="{() => count++}">
 আপনি {count} বার ক্লিক করেছেন
 </button>
md

md ফাইলে svelte ইম্পোর্ট

<script>
  import Counter from './Counter.svelte'
</script>
<Counter />
md
<script>
  let let count: numbercount = 
function $state<0>(initial: 0): 0 (+1 overload)
namespace $state

Declares reactive state.

Example:

let count = $state(0);
@seehttps://svelte.dev/docs/svelte/$state Documentation@paraminitial The initial value
$
function $state<0>(initial: 0): 0 (+1 overload)
namespace $state

Declares reactive state.

Example:

let count = $state(0);
@seehttps://svelte.dev/docs/svelte/$state Documentation@paraminitial The initial value
state
(0)
</script> <button onclick: () => numberonclick={() => let count: numbercount++}> আপনি {let count: numbercount} বার ক্লিক করেছেন </button>
svelte