我在vue中使用上下文菜单。代码用打字稿编写。
<div
v-for="(color, index) in colors"
class="colored-box"
:style="{background: color}"
@click="sayColor(color)"
@contextmenu.prevent="$refs.ctx.open($event, {color: color, index: index})">
</div>
<context-menu id="testingctx" ref="ctx" @ctx-open="onCtxOpen" @ctx-cancel="resetCtxLocals" @ctx-close="onCtxClose">
<li class="ctx-header">kkkk</li>
<li class="ctx-item">option one</li>
<li class="ctx-item disabled">option two (disabled)</li>
<li class="ctx-item">add to log</li>
</context-menu>
样本来自项目现场。 单击鼠标右键时显示错误:
Object doesn't support property or method 'open'