这是我的SFC
我评论了工作得很好和不工作得很好的部分
<template lang="pug">
.d3_simple
h1 My D3 Vue3 Example
svg(ref='svg_ref')
hr
div(ref='div_ref')
</template>
<script setup>
import { onMounted, ref } from 'vue'
import * as d3 from 'd3'
var svg_ref = $ref( null )
var div_ref = $ref( null )
// working
function d3_svg_ref()
{
d3.select( svg_ref )
.append( 'circle' )
.attr( 'cx', 50 )
.attr( 'cy', 50 )
.attr( 'r', 25 )
.style( 'fill', '#6fff00' )
}
// not working
function d3_div_ref()
{
var svg = d3.create( 'svg' )
.append( 'circle' )
.attr( 'cx', 50 )
.attr( 'cy', 50 )
.attr( 'r', 50 )
.style( 'fill', '#ffb300' )
d3.select( div_ref ).append( svg )
}
onMounted(
() =>
{
d3_svg_ref()
d3_div_ref()
}
)
</script>
获取错误Uncaught DOMException: String contains an invalid character
ps:keywords > len 3 -shouldn 't exist --请不要费心去注意它
看起来你的帖子大部分都是代码;请补充一些细节。
真的很傻,不用多说就很明显了~_~
1条答案
按热度按时间j7dteeu81#
GPT-3做的工作