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
当前 PWC 文件的写法如下:
<template> <div>Hello</div> </template> <script> export default class EditWord extends HTMLElement {} </script>
本 issue 主要讨论的是这个包的导出是什么?核心关系到在其他框架中的使用方式以及在 PWC 单文件体系内的使用方式
import 'pwc-picture'; export default function App() { return <pwc-picture /> }
当 pwc-picture 发生 break change 的时候,开发者需要去关注组件的文档上标明的标签名是什么,比如标签名的定义从 pwc-picture => pwc-picture-v2
pwc-picture
pwc-picture-v2
<template> <div>Hello</div> <Child /> </template> <script> import Child from './child'; export default class EditWord extends HTMLElement {} </script>
在该父组件的 template 内使用的 Child 最终会被映射修改为 Child 被定义的标签名
HTMLElement
export default
在 PWC 导出的组件中添加一个 named 导出 -- LocalName,并且统一 React 体系和 PWC 体系使用组件的方式:
named
LocalName
React:
import { LocalName: Picture } from 'pwc-picture'; // 或者 // import * as Picture from 'pwc-picture'; // return <Picture.LocalName /> export default function App() { return <Picture /> }
PWC:
<template> <div>Hello</div> <Child /> </template> <script> import { LocalName: Child } from './child'; export default class EditWord extends HTMLElement {} </script>
优势:
劣势:
忽略 PWC 单文件中原有的 export default,改为默认导出标签名,即写法为:
import Picture from 'pwc-picture'; export default function App() { return <Picture /> }
维持原有的方案
The text was updated successfully, but these errors were encountered:
方案一,PWC 的模板写法需要和 #41 结合来看。
Sorry, something went wrong.
No branches or pull requests
背景
当前 PWC 文件的写法如下:
本 issue 主要讨论的是这个包的导出是什么?核心关系到在其他框架中的使用方式以及在 PWC 单文件体系内的使用方式
原来的方案
在 React 体系内
当 pwc-picture 发生 break change 的时候,开发者需要去关注组件的文档上标明的标签名是什么,比如标签名的定义从
pwc-picture
=>pwc-picture-v2
在 PWC 单文件体系内
在该父组件的 template 内使用的 Child 最终会被映射修改为 Child 被定义的标签名
存在的问题是什么?
HTMLElement
类,在 React 体系中是利用 JS 文件引入的副作用定义的自定义标签export default
的值,并且导出的时候是当做字符串来用的解决方案
方案一(个人推荐)
在 PWC 导出的组件中添加一个
named
导出 --LocalName
,并且统一 React 体系和 PWC 体系使用组件的方式:React:
PWC:
优势:
劣势:
方案二
忽略 PWC 单文件中原有的
export default
,改为默认导出标签名,即写法为:优势:
劣势:
export default
导出的,和真实export default
导出的东西不一样方案三
维持原有的方案
The text was updated successfully, but these errors were encountered: