繁体   English   中英

错误 [E0412]:在此 scope 中找不到类型 `String`

[英]error[E0412]: cannot find type `String` in this scope

#![cfg_attr(not(feature = "std"), no_std)]

use ink_lang as ink;

#[ink::contract]

mod XYZ {

    #[ink(storage)]
    pub struct Xyz {
        token_id: u32,
        serial_code: String
    }
    ...
}

错误:

             serial_code: String
   |                      ^^^^^^ not found in this scope

基于——你应该使用ink!中包含String类型!

use ink_prelude::string::String;

并包含在正确的 Cargo.toml 文件中:

[Dependencies]
ink_prelude = { version = "2", git = "github.com/paritytech/ink", tag = "latest-v2", package = "ink_prelude", default-features = false }"

(或任何适合您的版本)

暂无
暂无

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

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