繁体   English   中英

如何从从 tns-core-modules 导入对象切换到 @nativescript/core?

[英]How do you switch from importing objects from tns-core-modules to @nativescript/core?

好的,所以我运行了命令“ns migrate”来使用更新版本的 nativescript。 这样做是删除 tns-core-modules 依赖项,这意味着我不能再使用它来导入东西了。 假设我们应该改用@nativescript/core,但问题是当我尝试导入对象时,@nativescript/core 不起作用,我收到“找不到模块'@nativescript/core'或其对应的类型声明”。

例如,这将不起作用:

import { Label } from "@nativescript/core";

但是有了 tns-core-modules 依赖,它就起作用了,而且很简单:

import { Label } from "tns-core-modules/ui/label"

运行 ns migrate 命令后,它会删除 tns-core-modules 并将 @nativescript/core 更新为 7.3.0

我是不是导入错误??

run npm install @nativescript/core

那么这应该工作

import { Label } from "@nativescript/core";

我用

import { ApplicationSettings, ImageSource } from '@nativescript/core';

在我最近的项目中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM