本文介绍了在 YAML 中重用代码块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想hashybzdhhdhmdhmdhm6ICZkZWZhdWx0cwogIENvbXBhbnk6IEZvbwogIEl0ZW06IDEyMwoKQ29tcHV0ZXI6ICpkZWcnolar>hashera iWrelArIWrArIWrif

I want to reuse a hash in YAML:

Defaults: &defaults
  Company: Foo
  Item: 123

Computer: *defaults
  Price: 3000

然而,这会产生一个错误.

However, this generates an error.

时以锚定每个域值分别这样中的唯一办法?

Is the only way to anchor each field value separately like this?

Defaults:
  Company: &company Foo
  Item: &item 123

Computer:
  Company: *company
  Item: *item
  Price: 3000

推荐答案

# sequencer protocols for Laser eye surgery
---
- step:  &id001                  # defines anchor label &id001
    instrument:      Lasik 2000
    pulseEnergy:     5.4
    pulseDuration:   12
    repetition:      1000
    spotSize:        1mm

- step: &id002
    instrument:      Lasik 2000
    pulseEnergy:     5.0
    pulseDuration:   10
    repetition:      500
    spotSize:        2mm

- step: *id001                   # refers to the first step (with anchor &id001)
- step: *id002                   # refers to the second step
- step: *id001
- step: *id002

来自维基百科的示例

这篇关于在 YAML 中重用代码块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 08:31