Activity 9a: Get the company name from bookstores
1. Understanding the Goal
从 bookstores JSON 对象中读取 name 属性,并在模板中显示该公司名称。
2. Step-by-Step Instruction
- Step 1: Ensure the
bookstoresobject is imported and available in the component. - Step 2: Access the
nameproperty viabookstores.name. - Step 3: Use Vue’s interpolation
{{ }}in the template to render the value.
3. Code Explanation
| 部分 | 说明 |
|---|---|
bookstores | 已导入的 JSON 对象,包含书店公司的各项信息。 |
bookstores.name | 访问对象的 name 属性,得到公司名称(字符串)。 |
{{ ... }} | Vue 插值语法,用于在模板中渲染变量的值。 |
<strong>...</strong> | 纯样式标签,用于将公司名称加粗显示(不影响数据逻辑)。 |