I need to integrate the function getCookie
into my Vue file. This function is already defined in the HTML file where the Vue file will be injected.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
<script>
function getCookie(cookie){
// do something
}
</script>
To use this function in my Vue file, I have to utilize the "declare" keyword.
<script setup lang="ts">
declare function getCookie(cookie: string): string;
However, this is not permitted with the script setup in Vue. An error message of "Modifiers cannot appear here" is displayed. Everything works fine if I avoid using script setup
.