script setup cannot work in vue2.7

This issue has been created since 2022-09-27.

Version

2.7.10

Reproduction link

codesandbox.io

Steps to reproduce

When I upgraded [email protected] in the old project , my code cannot work, However, I upgraded other projects to 2.7, everything is normal
So I guess there are other dependent effects ? I'm not sure .

<script setup>

const msg = 'Hello!';

console.log(msg);

function log() {

  console.log(msg);

}

</script>


<template>

<button @click="log">{{ msg }} </button>

</template>

error:

error-log.js?b1fc:32 TypeError: Cannot read properties of undefined (reading 'msg')

What is expected?

normal

What is actually happening?

error-log.js?b1fc:32 TypeError: Cannot read properties of undefined (reading 'msg')


this is my package.json, If there are other dependencies that affect ?

{

"dependencies": {

"@vue/babel-preset-app": "^4.5.4",

"clipboard": "2.0.4",

"codemirror": "5.45.0",

"core-js": "^3.6.5",

"cos-nodejs-sdk-v5": "^2.5.20",

"crypto-js": "^4.0.0",

"eslint-loader": "^4.0.0",

"excel-loader": "^1.0.1",

"file-saver": "^2.0.1",

"fuse.js": "3.4.4",

"hard-source-webpack-plugin": "^0.13.1",

"vant": "^2.9.3",

"vue": "^2.7.10",

"vue-router": "^3.6.5",

"vue-template-compiler": "^2.6.12",

"vue-virtual-scroller": "^1.0.9",

"vuedraggable": "2.20.0",

"vuex": "^3.6.2"

},

"devDependencies": {

"@babel/core": "7.0.0",

"@babel/register": "7.0.0",

"@carrotwu/check-vue-conflict-webpack-plugin": "^1.0.4",

"@types/jest": "^24.0.19",

"@typescript-eslint/eslint-plugin": "^4.18.0",

"@typescript-eslint/parser": "^4.18.0",

"@vue/cli-plugin-babel": "^4.5.4",

"@vue/cli-plugin-eslint": "^4.5.4",

"@vue/cli-plugin-typescript": "~4.5.13",

"@vue/cli-plugin-unit-jest": "^4.5.4",

"@vue/cli-service": "^4.5.4",

"@vue/eslint-config-typescript": "^7.0.0",

"@vue/test-utils": "1.0.0-beta.29",

"autoprefixer": "^9.5.1",

"axios": "^0.27.2",

"babel-core": "7.0.0-bridge.0",

"babel-eslint": "^10.1.0",

"babel-jest": "23.6.0",

"chokidar": "2.1.5",

"compression-webpack-plugin": "^6.1.1",

"connect": "3.6.6",

"cross-env": "^7.0.3",

"cz-conventional-changelog": "^3.3.0",

"deme": "^1.0.5",

"element-ui": "^2.15.7",

"eslint": "^7.28.0",

"eslint-config-prettier": "^8.3.0",

"eslint-plugin-prettier": "^4.0.0",

"eslint-plugin-vue": "^6.2.2",

"html-webpack-plugin": "3.2.0",

"husky": "^8.0.1",

"lint-staged": "8.1.5",

"mockjs": "1.0.1-beta3",

"node-sass": "^4.14.1",

"plop": "2.3.0",

"runjs": "^4.3.2",

"sass-loader": "^7.1.0",

"script-ext-html-webpack-plugin": "2.1.3",

"script-loader": "0.7.2",

"serve-static": "^1.13.2",

"speed-measure-webpack-plugin": "^1.3.3",

"svg-sprite-loader": "4.1.3",

"svgo": "1.2.0",

"typescript": "~4.1.5",

"vue-puzzle-vcode": "^1.1.3"

}
}

LinusBorg wrote this answer on 2022-09-27

PLeasse provide a runnable reproduction. the codesandbox you linked to does not demonstrate the problem described.

Also makes sure to have followed the upgrade guide here:

https://blog.vuejs.org/posts/vue-2-7-naruto.html#upgrade-guide

More Details About Repo
Owner Name vuejs
Repo Name vue
Full Name vuejs/vue
Language TypeScript
Created Date 2013-07-29
Updated Date 2022-12-10
Star Count 201155
Watcher Count 6070
Fork Count 33134
Issue Count 595

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
[Feature]: Second server url for fallback / local ip to external domain name swtich 4 2022-07-05 2022-12-08
Error on Compiling Workspace: No rule to make target '/home/user/anaconda3/lib/libcurl.so', needed by 'devel/lib/libget_file.so'. Stop 0 2022-03-28 2022-12-02
On iOS, after pressing a cluster and zooming, pressing a marker shows it and then quickly hides it 1 2022-11-27 2022-11-22
wierd maxZoom behavior 2 2019-02-08 2022-11-22
add Gradio Web Demo to cvpr 2022 organization 2 2022-06-12 2022-11-23
Text axis issue using Truetype fonts 0 2022-09-12 2022-09-24
Is the jacobian in body frame 4 2022-03-22 2022-11-24
Hide overlay icons when photo detail is clicked 5 2021-06-16 2022-10-21
Investigate and fix incorrect download dialog size on Linux 0 2022-07-25 2022-09-17
Permission not apply 4 2021-01-25 2022-10-07
Dragging route after loading route number from URL causes crash 0 2021-01-03 2022-11-21
Add property contentcreated 1 2021-02-27 2022-11-12
Position on 2.0 vs 1.x: We only include new features in 2.0 for now, add to 1.x later if required 2 2021-02-08 2022-11-17
Upgrade to LLVM 14.0 1 2022-03-25 2022-12-01
Possible to have an unified api for both ISPC and CPU 3 2021-03-06 2022-09-25
Uncaught exception in get_tokens_unprocessed 2 2021-12-16 2022-12-08
ch8中的视差图要怎样才能得到呢? 0 2021-04-01 2021-12-20
New bug report 0 2021-02-13 2022-01-15
[BUG]旧版本停止支持? 1 2021-07-15 2022-01-13
[NumberPicker]numberPicker没有默认值输出为字符串 0 2022-02-28 2022-10-06
FileAttachment 1 2021-05-17 2022-01-22
RIP highsource :-( 0 2021-06-24 2022-01-13
Reservation mastery calculation bug 0 2022-09-08 2022-10-16
workbench.colorCostumizations deleted on remote connect 5 2021-08-27 2022-11-15
Document how to use the Arduino IDE with git master 2 2022-05-30 2022-10-26
Error deploying bundle in K8s model 5 2021-06-04 2022-11-04
How the get only the actual rendered sprites 1 2020-11-06 2022-11-29
Replacing a template part does not prompt saving the template 7 2021-10-06 2022-11-26
Mega-cmd sync output 9 2021-01-07 2022-11-01
Code snippets are missing highlight markers 1 2021-11-09 2022-01-15
Prow error flushing action history to GCS: permission issue 4 2021-09-17 2022-12-10
[25.0.0 beta 6]: Context menu not working 1 2022-09-19 2022-12-01
Mute on the right sound channel (Raphael) 2 2021-12-04 2022-11-25
RV32E instruction set support 1 2021-05-26 2022-12-07
tcp_sockets (+2 LANG) failing tests under CentOS 8.3 kernel 4.18.0 20 2021-12-23 2022-12-09
Switch the changelog to an F-Droid compatible format 1 2018-08-28 2022-11-02
After converting pytorch yolov5_1 model to onnx, onnx model is predicting 1000 boxes. why onnx predicting thousands of boxes after conversion 6 2021-10-28 2022-09-06
Check if autoscalar should be down when doing kubernetes upgrade 0 2022-11-25 2022-12-01
Register / Update models for multiple TorchServe Containers 1 2022-02-15 2022-11-24
Improved logging for HTML report failures. 2 2021-06-16 2022-07-23
Interrupts? 3 2020-10-15 2022-01-11
Inventory Holder in InventoryClickEvent is weird 1 2022-02-01 2022-12-03
Outer product 0 2022-01-20 2022-01-14
git.rebaseWhenSync true does not affect git.postCommitCommand sync 0 2022-05-06 2022-08-20
Windows script contains multiple issues. 1 2020-11-06 2022-11-22
Let spark history logger handle events asynchronously 0 2021-09-06 2022-09-24
What is the role of 'clipped_count_stddev' in differentially private gaussian_adaptive aggregator? 4 2021-12-02 2022-12-08
🐛[BUG] 折线图 当 smooth 配置为true, 时, 无法触发 ‘element:click’ 等事件 0 2022-04-09 2022-12-08
Deploy fails unnecessarily on temporary image pull error 12 2021-04-28 2022-12-05
Send product review. 0 2021-07-25 2022-12-09