JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<script src="https://unpkg.com/vue@next"></script>
<!-- import CSS -->
<link rel="stylesheet" href="https://unpkg.com/element-plus/lib/theme-chalk/index.css">
<!-- import JavaScript -->
<script src="https://unpkg.com/element-plus/lib/index.full.js"></script>
<title>Element Plus demo</title>
<style>
.element-plus-loading .element-plus-loading__box1 {
height: 300px;
background: #ccc;
display: flex;
justify-content: center;
align-items: center;
font-size: 2em;
}
</style>
</head>
<body>
<div id="app">
<div class="element-plus-loading">
<div class="element-plus-loading__box1" v-loading="loading">
注意看我: {{ loading }}
</div>
</div>
</div>
<script>
const { ref, reactive, toRefs, compile, currentInstance } = Vue
const App = {
setup() {
// render函数
const renderFn = compile(`
<div class="element-plus-loading">
<div class="element-plus-loading__box1" v-loading="loading">
注意看我: {{ loading }}
</div>
</div>
`)
console.log('render函数打印:', String(renderFn))
// 使用ref 创建响应式数据时, (开发环境)模板编译有问题,导致执行不到 element-plus/packages/loading/src/directive.ts中的钩子
const loading = ref(true)
setTimeout(() => {
loading.value = false
}, 3 * 1000)
return {
loading
}
// 使用reactive 创建的响应式数据, 一切和预期一样
// const status = reactive({ loading: true })
// setTimeout(() => {
// status.loading = false
// }, 3*1000)
// return {
// ...toRefs(status)
...