然而不要解构 props 对象,那样会使其失去响应性:
export default {
props: {
name: String,
},
setup({ name }) {
watchEffect(() => {
console.log(`name is: ` + name) // Will not be reactive!
Tailwind.css online 一定要配合 focus 一起使用 | |
``` | |
focus:outline-none | |
``` |
Vue Composition API 的 setup() 晚于 beforeCreate 钩子(在 Vue 中,“钩子”就是一个生命周期方法)而早于 created 钩子被调用。 | |
这是我们可以分辨 React Hooks 和 Vue Composition API 的首个区别, React hooks 会在组件每次渲染时候运行,而 Vue setup() 只在组件创建时运行一次。 | |
因为前者可以多次运行,所以 render 方法必须遵守 某些规则,其中之一是: | |
> 不要在循环内部、条件语句中或嵌套函数里调用 Hooks |
然而不要解构 props 对象,那样会使其失去响应性:
export default {
props: {
name: String,
},
setup({ name }) {
watchEffect(() => {
console.log(`name is: ` + name) // Will not be reactive!
<template> | |
<button @click="onClick">{{ copied ? "copied" : "copy" }}</button> | |
</template> | |
<script> | |
import { ref, watchEffect } from "vue"; | |
export default { | |
setup() { | |
const copied = ref(false); |
defmodule Jstore do | |
@moduledoc """ | |
Documentation for `Jstore`. | |
""" | |
@doc """ | |
Hello world. | |
## Examples |
预请求:使用 https://instant.page/
cache: <nuxt alive />
https://nuxtjs.org/api/pages-fetch#caching
auth refetch on window focus: https://react-query.tanstack.com/docs/guides/window-focus-refetching
// ref: https://nuxtjs.org/guides/features/file-system-routing#scrollbehavior | |
// ~/app/router.scrollBehavior.js | |
export default function (to, from, savedPosition) { | |
if (savedPosition) { | |
return savedPosition; | |
} else { | |
return { x: 0, y: 0 }; | |
} | |
} |
// response | |
// { | |
// code: string | |
// msg: string | |
// data: any | |
// } | |
export const spreadResponse = (res) => { | |
const { | |
data: { data }, | |
} = res |
--- | |
swagger: '2.0' | |
info: | |
description: "This is a sample Petstore server. You can find \nout more about Swagger at \n[http://swagger.io](http://swagger.io) or on \n[irc.freenode.net, #swagger](http://swagger.io/irc/).\n" | |
version: 1.0.0 | |
title: Swagger Petstore | |
termsOfService: http://swagger.io/terms/ | |
contact: | |
email: [email protected] | |
license: |
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |