我想在md文件中引用config.js定义的全局变量,应该怎么做? #1622
-
如题,全局变量应该定义在哪里?md文件应该怎么引用? |
Beta Was this translation helpful? Give feedback.
Answered by
Mister-Hope
Dec 7, 2024
Replies: 1 comment 2 replies
-
import { defineClientConfig } from 'vuepress/client'
export default defineClientConfig({
enhance({ app }) {
Object.defineProperties(app.config.globalProperties, {
$a: {
get() {
return '123'
},
},
})
}
}) In markdown file: ${{ $a }} You will get |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Louis-XIV
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.vuepress/client.js
:In markdown file:
You will get
123
in render result.