小编jac*_*eo7的帖子

如何在 Vue 中根据链接是外部还是内部动态渲染 <router-link> 或 <a>?

<template>
  <component
    :is="type === 'internal' ? 'router-link' : 'a'"
    :to="type === 'internal' ? link : null"
    :href="type !== 'internal' ? link : null"
  >
    <slot />
  </component>
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";

@Component
export default class SiteLink extends Vue {
  @Prop({
    validator: (value: string) =>
      ["external", "internal"].includes(value)
  })
  private readonly type!: string;

  @Prop({ type: String })
  private readonly link!: string;
}
</script>
Run Code Online (Sandbox Code Playgroud)

上面是一个 Vue 组件,它将在其中呈现一个链接。我已经删除了与问题无关的任何内容(即reltargetclass等)。

理解- 我对 …

html hyperlink typescript vue.js vue-router

5
推荐指数
2
解决办法
1万
查看次数

使用 npm 任务与在 Azure 管道中使用脚本有什么区别?

在执行 npm 安装时,我正在努力找出 Azure 管道的以下两个片段之间的差异。

片段 1(使用任务):

- task: Npm@1
  inputs:
    command: 'install'
Run Code Online (Sandbox Code Playgroud)

片段 2(使用脚本):

- script: npm install
Run Code Online (Sandbox Code Playgroud)

我唯一的猜测是一个比另一个性能更好?另外,是否推荐一种方法而不是另一种方法?

azure-pipelines azure-pipelines-yaml

2
推荐指数
1
解决办法
2248
查看次数