Src attribute usage
The src
attribute value can be a URL
or a script ID
. Used to indicate how the component should get the data.
URL
跳转到“URL”src="URL"
It can be a relative path or an absolute path, used to get data from the interface.
<spz-render layout="container" src="/api/product/xxxxx">
<!-- ... -->
</spz-render>
Script ID
跳转到“Script ID”src="script:#scriptID"
Use the form of script to configure data, and the data
returned by the final component is the content in the script. It already supports the following components:
- spz-area
- spz-render
- spz-variant
<script id="render-data" type="application/json">
[
{
"id": "1",
"title": "Product 1"
},
{
"id": "2",
"title": "Product 2"
}
]
</script>
<spz-render layout="container" src="script:render-data">
<template>
<div>
${data.map(item => (
`<div>${item.id} - ${item.title}</div>`
)).join('')}
</div>
</template>
</spz-render>
<!-- Template render results: -->
<div>
<div>1 - Product 1</div>
<div>2 - Product 2</div>
</div>