我是angular2的新手。我在尝试使用
从外部 .ts 文件读取const时遇到问题import {apis} from '../constants/apis';
其中常量/ apis.ts 文件为:
export const apis = {
lookUp: "api/getLookup.php"
}
它给出了一个错误 获取http://localhost:3000/constants/apis 404(未找到)
我该如何解决这个问题?
我使用的是 VSCode , VSCode 建议使用路径'../constants/apis'
,这是正确的。
答案 0 :(得分:0)
试着写下这个:
extension UITextView {
func hyperLink(originalText: String, hyperLink: String, urlString: String) {
let style = NSMutableParagraphStyle()
style.alignment = .left
let attributedOriginalText = NSMutableAttributedString(string: originalText)
let linkRange = attributedOriginalText.mutableString.range(of: hyperLink)
let fullRange = NSMakeRange(0, attributedOriginalText.length)
attributedOriginalText.addAttribute(NSAttributedStringKey.link, value: urlString, range: linkRange)
attributedOriginalText.addAttribute(NSAttributedStringKey.paragraphStyle, value: style, range: fullRange)
attributedOriginalText.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.blue, range: fullRange)
attributedOriginalText.addAttribute(NSAttributedStringKey.font, value: UIFont.systemFont(ofSize: 10), range: fullRange)
self.linkTextAttributes = [
kCTForegroundColorAttributeName: UIColor.blue,
kCTUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue,
] as [String : Any]
self.attributedText = attributedOriginalText
}
}
您可以找到答案here