spikijs 1.1.26 → 1.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,10 @@ SpikiJS enforces strict security and architectural separation of concerns:
|
|
|
26
26
|
2. **No Attribute Parameters:** Function parameters are not supported inside HTML attributes (e.g. `s-click="save(item)"` is invalid).
|
|
27
27
|
- **Correct Pattern:** Bind only the method name (`s-click="save"`). Inside loop templates, Spiki automatically injects context variables directly into `this` (e.g. `this.item`, `this.index`).
|
|
28
28
|
|
|
29
|
-
3. **
|
|
29
|
+
3. **No Dot Modifiers:** Attribute names do **NOT** support dots (`.`) or modifier suffixes (e.g. `s-submit.prevent="submitForm"` is invalid).
|
|
30
|
+
- **Correct Pattern:** Bind clean directive names (`s-submit="submitForm"`). Handle event options like `e.preventDefault()` directly inside your JS method.
|
|
31
|
+
|
|
32
|
+
4. **State Access via `this`:** All data reading and state mutations must be performed inside component methods using the `this` context (e.g. `this.count++`).
|
|
30
33
|
|
|
31
34
|
---
|
|
32
35
|
|
|
@@ -39,11 +42,49 @@ Include SpikiJS via script tag. Spiki automatically exposes `window.spiki`:
|
|
|
39
42
|
<script src="https://unpkg.com/spikijs"></script>
|
|
40
43
|
```
|
|
41
44
|
|
|
42
|
-
###
|
|
45
|
+
### ES Module / NPM
|
|
46
|
+
Install SpikiJS via npm package manager:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install spikijs
|
|
50
|
+
```
|
|
51
|
+
|
|
43
52
|
Import SpikiJS directly as an ES module:
|
|
44
53
|
|
|
45
54
|
```javascript
|
|
46
|
-
import spiki from '
|
|
55
|
+
import spiki from 'spikijs';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<div s-data="counterApp">
|
|
64
|
+
<h2>Count: <span s-text="count"></span></h2>
|
|
65
|
+
<button s-click="increment">+</button>
|
|
66
|
+
<button s-click="decrement">-</button>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<script type="module">
|
|
70
|
+
import spiki from 'spikijs';
|
|
71
|
+
|
|
72
|
+
// 1. Register Component State & Methods
|
|
73
|
+
spiki.data('counterApp', () => ({
|
|
74
|
+
count: 0,
|
|
75
|
+
increment() {
|
|
76
|
+
this.count++;
|
|
77
|
+
},
|
|
78
|
+
decrement() {
|
|
79
|
+
this.count--;
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
// 2. Start Engine
|
|
84
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
85
|
+
spiki.start();
|
|
86
|
+
});
|
|
87
|
+
</script>
|
|
47
88
|
```
|
|
48
89
|
|
|
49
90
|
---
|