Sfoglia il codice sorgente

add $router.not method

Shaun 2 anni fa
parent
commit
df03b95775
3 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 2 1
      README.md
  2. 1 1
      package.json
  3. 3 0
      src/index.js

+ 2 - 1
README.md

@@ -255,7 +255,8 @@ Declare routes by creating a template tag with `x-route` attribute.
 
 <!-- Check if the route matches the current location -->
 <div x-show="$router.is('/path/to/route')">You can see me</div>
-<template x-if="$router.is('/path/to/route1', '/path/to/route2', ...)">You can see me</template>
+<template x-if="$router.is('/path/to/route1', '/path/to/route2', ...)">You can see me also</template>
+<div x-show="$router.not('/path/to/route')">...</div>
 ```
 
 ## License

+ 1 - 1
package.json

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

+ 3 - 0
src/index.js

@@ -48,6 +48,9 @@ export default function (Alpine) {
 
     is (...paths) {
       return is({ paths })
+    },
+    not (...paths) {
+      return !is({ paths })
     }
   }