Browse Source

bind router to Alpine.$router

Shaun 2 năm trước cách đây
mục cha
commit
9a7c2ebde9
3 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 3 0
      examples/index.html
  2. 1 1
      package.json
  3. 1 0
      src/index.js

+ 3 - 0
examples/index.html

@@ -109,6 +109,9 @@
           <div class="px-16 py-4">
             <code>$router: <span x-text="JSON.stringify($router)"></span></code>
           </div>
+          <div class="px-16 py-4">
+            <code>Alpine.$router: <span x-text="JSON.stringify(Alpine.$router)"></span></code>
+          </div>
         </footer>
       </div>
     </div>

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@shaun/alpinejs-router",
-  "version": "1.2.10",
+  "version": "1.2.11",
   "description": "Easy to use and flexible router for Alpine.js",
   "type": "module",
   "main": "dist/module.cjs.js",

+ 1 - 0
src/index.js

@@ -54,6 +54,7 @@ export default function (Alpine) {
     }
   }
 
+  Alpine.$router = route
   Alpine.magic('router', () => route)
 
   function getTargetURL (href) {