Composable Vue, 编写可组合可复 的Vue 函数的最佳实践与技巧{ return { dark: false } }, computed: { light() { return !this.dark } }, methods: { toggleDark() { this.dark = !this.dark } } } setup() { const dark = ref(false) const light = computed(() => !dark.value) return { dark, light, toggleDark() { dark.value = !dark.value } } 什么是可组合的函数 Dark 可复⽤逻辑的集合,专注点分离 export function useDark(options: UseDarkOptions = {}) { const preferredDark = usePreferredDark() // <-- const store = useLocalStorage('vueuse-dark', 'auto')0 码力 | 36 页 | 4.87 MB | 1 年前3
PyWebIO v1.8.2 使用手册from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之后每次调用 show_time() , 输出域都会被新的内容覆盖。 Scope 支持嵌套。会话开始时,PyWebIO 模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading.Thread(target=show_time) register_thread(t) put_markdown('## Clock') t.start() # run `show_time()` in background # this thread will cause `SessionNotFoundException` threading.Thread(target=show_time).start() put_text('Background task started.')0 码力 | 137 页 | 1.76 MB | 1 年前3
PyWebIO v1.8.2 使用手册from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之后每次调用 show_time() , 输出域都会被新的内容覆盖。 Scope 支持嵌套。会话开始时,PyWebIO 模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading.Thread(target=show_time) register_thread(t) put_markdown('## Clock') t.start() # run `show_time()` in background # this thread will cause `SessionNotFoundException` threading.Thread(target=show_time).start() put_text('Background task started.')0 码力 | 137 页 | 1.76 MB | 1 年前3
PyWebIO v1.8.2 使用手册from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之后每次调用 show_time() , 输出域都会被新的内容覆盖。 Scope 支持嵌套。会话开始时,PyWebIO 模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading.Thread(target=show_time) register_thread(t) put_markdown('## Clock') t.start() # run `show_time()` in background # this thread will cause `SessionNotFoundException` threading.Thread(target=show_time).start() put_text('Background task started.')0 码力 | 135 页 | 1.75 MB | 1 年前3
PyWebIO v1.8.0 使用手册from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之后每次调用 show_time() , 输出域都会被新的内容覆盖。 Scope 支持嵌套。会话开始时,PyWebIO 模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading.Thread(target=show_time) register_thread(t) put_markdown('## Clock') t.start() # run `show_time()` in background # this thread will cause `SessionNotFoundException` threading.Thread(target=show_time).start() put_text('Background task started.')0 码力 | 135 页 | 1.75 MB | 1 年前3
PyWebIO v1.8.1 使用手册from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之后每次调用 show_time() , 输出域都会被新的内容覆盖。 Scope 支持嵌套。会话开始时,PyWebIO 模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading.Thread(target=show_time) register_thread(t) put_markdown('## Clock') t.start() # run `show_time()` in background # this thread will cause `SessionNotFoundException` threading.Thread(target=show_time).start() put_text('Background task started.')0 码力 | 135 页 | 1.75 MB | 1 年前3
PyWebIO v1.8.2 使用手册scope2 text in parent scope of scope2 use_scope() 还可以作为装饰器来使用: 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之 后每次调用 show_time() ,输出域都会被新的内容覆盖。 Scope支持嵌套。会话开始时,PyWebIO应用只有一个 ROOT scope。你可以在一 个scope中创建新 previous content put_text('text in scope2') from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) with use_scope('A'): put_text('Text in scope A') 异 常。 Server模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading0 码力 | 160 页 | 7.48 MB | 1 年前3
PyWebIO v1.8.2 使用手册scope2 text in parent scope of scope2 use_scope() 还可以作为装饰器来使用: 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之 后每次调用 show_time() ,输出域都会被新的内容覆盖。 Scope支持嵌套。会话开始时,PyWebIO应用只有一个 ROOT scope。你可以在一 个scope中创建新 previous content put_text('text in scope2') from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) with use_scope('A'): put_text('Text in scope A') 异 常。 Server模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading0 码力 | 160 页 | 7.48 MB | 1 年前3
PyWebIO v1.8.1 使用手册scope2 text in parent scope of scope2 use_scope() 还可以作为装饰器来使用: 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之 后每次调用 show_time() ,输出域都会被新的内容覆盖。 Scope支持嵌套。会话开始时,PyWebIO应用只有一个 ROOT scope。你可以在一 个scope中创建新 previous content put_text('text in scope2') from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) with use_scope('A'): put_text('Text in scope A') 异 常。 Server模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading0 码力 | 158 页 | 7.48 MB | 1 年前3
PyWebIO v1.8.0 使用手册scope2 text in parent scope of scope2 use_scope() 还可以作为装饰器来使用: 第一次调用 show_time 时,将会创建 time 输出域并在其中输出当前时间,之 后每次调用 show_time() ,输出域都会被新的内容覆盖。 Scope支持嵌套。会话开始时,PyWebIO应用只有一个 ROOT scope。你可以在一 个scope中创建新 previous content put_text('text in scope2') from datetime import datetime @use_scope('time', clear=True) def show_time(): put_text(datetime.now()) with use_scope('A'): put_text('Text in scope A') 异 常。 Server模式下多线程的使用示例: def show_time(): while True: with use_scope(name='time', clear=True): put_text(datetime.datetime.now()) time.sleep(1) def app(): t = threading0 码力 | 157 页 | 7.48 MB | 1 年前3
共 662 条
- 1
- 2
- 3
- 4
- 5
- 6
- 67













