Import 如何将对象从tns核心模块导入到@nativescript/core?
好的,所以我运行了命令“ns migrate”来使用更新版本的nativescript。这样做的目的是删除tns核心模块依赖项,这意味着我不能再使用它来导入内容。我们应该改用@nativescript/core,但问题是当我尝试导入对象@nativescript/core时,出现了“找不到模块'@nativescript/core'或其相应的类型声明” 例如,这将不起作用:Import 如何将对象从tns核心模块导入到@nativescript/core?,import,module,nativescript,migrate,Import,Module,Nativescript,Migrate,好的,所以我运行了命令“ns migrate”来使用更新版本的nativescript。这样做的目的是删除tns核心模块依赖项,这意味着我不能再使用它来导入内容。我们应该改用@nativescript/core,但问题是当我尝试导入对象@nativescript/core时,出现了“找不到模块'@nativescript/core'或其相应的类型声明” 例如,这将不起作用: import { Label } from "@nativescript/core"; 但使用tns
import { Label } from "@nativescript/core";
但使用tns核心模块依赖项,它可以工作,并且非常简单:
import { Label } from "tns-core-modules/ui/label"
运行ns migrate命令后,它将删除tns核心模块,并将@nativescript/core更新为7.3.0
我的导入错误吗
run npm install @nativescript/core
那么这就行了
import { Label } from "@nativescript/core";
我用
在我最近的项目中就是这样做的。哇!我发誓我以为我已经安装好了。。。我真傻。我将在4分钟内投票并接受作为答案,当它允许我如何更改此导入?const{fromObject}=require('tns-core-modules/data/observable')没有区别,从“@nativescript/core”使用导入{fromObject}”;
import { ApplicationSettings, ImageSource } from '@nativescript/core';