This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function CustomRef(value, name) { | |
| return customRef((track, trigger) => { | |
| return { | |
| get() { | |
| track(); | |
| try { | |
| return JSON.parse(localStorage.getItem(`my_local_${name}`)); | |
| } catch (error) { | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ref } from 'vue'; | |
| const count = ref(''); | |
| export const useCount = () => { | |
| return { | |
| count | |
| }; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { CustomRef } from './utils/custom-refs'; | |
| const count = new CustomRef('', 'count'); | |
| export const useCount = () => { | |
| return { | |
| count | |
| }; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <h2>Counter</h2> | |
| <h3>count: {{count}}</h3> | |
| <button @click="count--">Down</button> | |
| <button @click="count++">Up</button> | |
| </template> | |
| <script setup> | |
| const { count } = useCount(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default defineNuxtPlugin(() => { | |
| addRouteMiddleware('router', (to, from) => { | |
| if(!to.query.is_from){ | |
| to.query.is_from = from.query.is_from; | |
| return navigateTo(to, { redirectCode: 301 }) | |
| } | |
| }, { global: true }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { defineNuxtConfig } from 'nuxt' | |
| export default defineNuxtConfig({ | |
| vite: { | |
| server: { | |
| proxy: { | |
| "/api": { | |
| target: "https://your-api-server.co", | |
| changeOrigin: true, | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style scoped> | |
| .example { | |
| color: red; | |
| } | |
| </style> | |
| <template> | |
| <div class="example">hi</div> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function(){ | |
| var e = {{Click Element}}; | |
| var closestEle = e.closest('[data-woo]'); | |
| return closestEle.dataset.woo; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div> | |
| <app-modal | |
| title="This is modal" | |
| :visible.sync="modalVisible"> | |
| <div> | |
| This is modal body | |
| </div> | |
| </app-modal> | |
| <button @click="handleClickModalSwitch">Open Modal</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div> | |
| <app-parent /> | |
| <button @click="handleClickModalSwitch">Open Modal</button> | |
| </div> | |
| </template> | |
| <script> | |
| import { mapActions } from "vuex"; | |
| import AppParent from "./Parent.vue"; |
NewerOlder