We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在 vitepress 文档中链接到运行 @vue/repl 的页面,弹了个 Alert 显示 Failed to load code from URL. 无法正常打开代码示例
@vue/repl
在链接生成后,使用了 vitepress 的 withBase 来处理链接:
withBase
<a :href="withBase(`/playground${serializedCode}`)" target="_blank" rel="noreferrer noopener">{{ text || i18n.openInPlayground }}</a>
serializedCode 是 @vue/repl store.serialize() 生成的字符串
serializedCode
store.serialize()
具体查看 vitepress withBase 调用的 joinPath 源码:
joinPath
/** * Join two paths by resolving the slash collision. */ export function joinPath(base: string, path: string) { return `${base}${path}`.replace(/\/+/g, '/') }
可以看到这个函数对整个参数进行了一次 replace
replace
由于 @vue/repl 生成的是 base64 编码的字符串,其中也包含 / 字符,因此经过 withBase 处理之后,就无法进行 base64 解码了
/
把 @vue/repl 生成的字符串放在 withBase 之外可解决
<a :href="withBase('/playground') + serializedCode" target="_blank" rel="noreferrer noopener">{{ text || i18n.openInPlayground }}</a>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
背景
在 vitepress 文档中链接到运行
@vue/repl
的页面,弹了个 Alert 显示 Failed to load code from URL. 无法正常打开代码示例问题分析
在链接生成后,使用了 vitepress 的
withBase
来处理链接:serializedCode
是@vue/repl
store.serialize()
生成的字符串具体查看 vitepress
withBase
调用的joinPath
源码:可以看到这个函数对整个参数进行了一次
replace
由于
@vue/repl
生成的是 base64 编码的字符串,其中也包含/
字符,因此经过withBase
处理之后,就无法进行 base64 解码了解决
把
@vue/repl
生成的字符串放在withBase
之外可解决The text was updated successfully, but these errors were encountered: