'|'或运算符在vuejs src代码“vnode.js”中的含义?

时间:2017-01-03 03:25:52

标签: vue.js

我想知道|操作员的意思,谁能解释一下? 这是src / core / vdom / vnode.js中的一些简短代码片段

export default class VNode {
  tag: string | void;
  data: VNodeData | void;
  children: ?Array<VNode>;
  text: string | void;
  elm: Node | void;
  ns: string | void;
  context: Component | void; // rendered in this component's scope
  functionalContext: Component | void; // only for functional component root nodes
  key: string | number | void;
  componentOptions: VNodeComponentOptions | void;
  child: Component | void; // component instance
  parent: VNode | void; // component placeholder node
  raw: boolean; // contains raw HTML? (server only)
  isStatic: boolean; // hoisted static node
  isRootInsert: boolean; // necessary for enter transition check
  isComment: boolean; // empty comment placeholder?
  isCloned: boolean; // is a cloned node?
  isOnce: boolean; // is a v-once node?

1 个答案:

答案 0 :(得分:-1)

此处|是OR一元运算符。

ns: string | void;

表示ns的类型为string,但如果由于某种原因未定义string,则其类型为void。如果没有在某些浏览器版本中定义,这应该仅用于预防措施。