瀏覽代碼

Upgrade version && write docs for x-init

Caleb Porzio 5 年之前
父節點
當前提交
5ef118f77d
共有 2 個文件被更改,包括 13 次插入3 次删除
  1. 12 2
      README.md
  2. 1 1
      package.json

+ 12 - 2
README.md

@@ -12,7 +12,7 @@ Think of it like [Tailwind](https://tailwindcss.com/) for JavaScript.
 
 **From CDN:** Add the following script to the end of your `<head>` section.
 ```html
-<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v1.2.0/dist/alpine.js" defer></script>
+<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v1.3.0/dist/alpine.js" defer></script>
 ```
 
 That's it. It will initialize itself.
@@ -82,11 +82,12 @@ You can even use it for non-trivial things:
 
 ## Learn
 
-There are 11 directives available to you:
+There are 12 directives available to you:
 
 | Directive
 | --- |
 | [`x-data`](#x-data) |
+| [`x-init`](#x-init) |
 | [`x-show`](#x-show) |
 | [`x-bind`](#x-bind) |
 | [`x-on`](#x-on) |
@@ -145,6 +146,15 @@ You can also mix-in multiple data objects using object destructuring:
 
 ---
 
+### `x-init`
+**Example:** `<div x-data"{ foo: 'bar' }" x-init="foo = 'baz"></div>`
+
+**Structure:** `<div x-data="..." x-init="[expression]"></div>`
+
+`x-init` runs an expression (with the initial data object in scope) when a component is initialized.
+
+---
+
 ### `x-show`
 **Example:** `<div x-show="open"></div>`
 

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "main": "dist/alpine.js",
   "name": "alpinejs",
-  "version": "1.2.0",
+  "version": "1.3.0",
   "repository": {
     "type": "git",
     "url": "git://github.com/alpinejs/alpine.git"