Subscribe on changes!

vue3.2x use <script setup>, Build does not resolve computed properties in :src="require()"

avatar
Apr 7th 2022

Version

3.2.31

Reproduction link

stackoverflow.com

Steps to reproduce

<template>
    <img :src="require(`@/assets/images/icon_num_${state.lotteryNum}.png`)" alt="" />
</template>
<script setup lang="ts">
import {reactive} from 'vue'
const state = reactive({
    lotteryNum:1,
})
</script>

When running locally, there is no problem. But after packaging, the console will report an error when running online. error message: ReferenceError: _unref is not defined.

CZAZD

What is expected?

Display pictures normally, no error.

What is actually happening?

When running locally, there is no problem. But after packaging, the console will report an error when running online. error message: ReferenceError: _unref is not defined


I tried not to use