小编Cha*_*lha的帖子

错误:querySrv ENOTFOUND _mongodb._tcp.dbname.fzofb.mongodb.net

我正在学习 Node.js,刚刚开始使用 MongoDB。

我正在与我创建的 MongoDB 集群建立连接

const dbURI = 'mongodb+srv://testuser:test1234@nodelearning.fzofb.mongodb.net/mydb?retryWrites=true&w=majority';
mongoose.connect(dbURI, { useNewUrlParser: true, useUnifiedTopology: true })
    .then((result) => console.log('connected to db'))
    .catch((err) => console.log(err));
Run Code Online (Sandbox Code Playgroud)

当我运行它时,nodemon app我收到此错误:

错误:querySrv ENOTFOUND _mongodb._tcp.mydb.fzofb.mongodb.net at QueryReqWrap.onresolve [as oncomplete] (node:dns:206:19) { errno: 未定义,代码:'ENOTFOUND',系统调用:'querySrv',
主机名: '_mongodb._tcp.mydb.fzofb.mongodb.net' }

javascript mongoose mongodb node.js express

3
推荐指数
2
解决办法
2万
查看次数

UIView帧大小没有改变UIImageView放在它里面

我正在框架中制作图片,然后用户可以在运行时调整帧大小.为了这个目的,我已经UIView在我的主要UIViewController内部和内部做了一个习惯,我UIView放置了2 UIImageView.在xCode的Document Outline Pane中,它的层次结构是:


查看
| --ImageView
| --ImageView

我正在使用这行代码来改变UIView不同条件下的大小,它会相应调整大小:

self.imageObject.frame = CGRectMake(self.imageObject.frame.origin.x , 
                                    self.imageObject.frame.origin.y, 
                                    200, 
                                    200);
Run Code Online (Sandbox Code Playgroud)

imageObject是我的UIView.当我运行它时,UIView更改的大小,但UIImageView大小保持不变.我也试过为我做同样的事情,UIImageView但它没有用.

objective-c uiview uiimageview ios cgrectmake

2
推荐指数
1
解决办法
5921
查看次数

如何修复任务:app:mergereleaseresources在反应本机发布apk构建中失败

我正在尝试在 React Native 中发布 apk,但出现此错误 task :app:mergereleaseresources failed

如果我删除可绘制和原始文件夹并再次构建,则会收到此错误:

任务“:app:mergeBetaReleaseResources”执行失败。

React Native生成apk的流程

  1. 创建密钥库

  2. react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

  3. cd android

  4. ./gradlew assembleRelease

请帮忙。

android react-native

2
推荐指数
1
解决办法
7872
查看次数

当用户拒绝访问以允许通知时如何获取 FCM 令牌

由于后端的要求,这是我第一次使用 firebase,所以如果您不理解这个问题或者它没有任何意义,请告诉我。

我想要实现的是,Registration_ID当用户注册时,我需要一个FCM 令牌。所以这就是我在AppDelegate.swift> 中实施它的方式didFinishLaunchingWithOptions

if #available(iOS 10.0, *) {
            // For iOS 10 display notification (sent via APNS)
            UNUserNotificationCenter.current().delegate = self

            let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
            UNUserNotificationCenter.current().requestAuthorization(
                options: authOptions,
                completionHandler: {_, _ in })
        } else {
            let settings: UIUserNotificationSettings =
                UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
            application.registerUserNotificationSettings(settings)
        }

        application.registerForRemoteNotifications()
Run Code Online (Sandbox Code Playgroud)

在那之后,AppDelegate.swift我添加了这三个功能:

func application(_ application: UIApplication,
                     didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Messaging.messaging().apnsToken = deviceToken as Data
    }

    func messaging(_ messaging: Messaging, didRefreshRegistrationToken …
Run Code Online (Sandbox Code Playgroud)

ios firebase swift3 firebase-cloud-messaging

1
推荐指数
1
解决办法
1795
查看次数

UIImageViewcornerRadius 没有让它圆

我有一个视图控制器,它显示在 a 中,UIView因为我正在使用CarbonKit制作类似 android 的选项卡。

我有一个userProfileViewController我在其中一个选项卡下显示的,这是UIImageView我试图通过使用以下代码在圆圈中显示的:

self.userDisplayPic.layer.cornerRadius = self.userDisplayPic.frame.size.width / 2;
self.userDisplayPic.clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)

结果是: 在此处输入图片说明

我的猜测是,这可能是因为在内部显示时自动调整大小UIView可能会压缩设计,但其他元素特别是更新按钮似乎很好。所以有什么建议可以解决这个问题吗?

uiview uiimageview ios swift4

1
推荐指数
1
解决办法
2164
查看次数

无法从 node_modules\uuidv4\build\lib\uuidv4.js 解析模块 util

这个标题有一些问题,但我有。尝试了其中的所有解决方案,但我无法解决这个问题。

我刚刚开始学习 React-Native 并收到此错误:

在此输入图像描述

我已经尝试过这个红色框中提到的步骤。我尝试删除node_modules文件夹然后重新安装。我也换了"uuidv4": "^5.0.1"版本,npm install重新安装了。但没有成功。我使用过的代码uuidv4是:

const [items, setItems] = useState([
    { id: uuid(), text: 'Milk' },
    { id: uuid(), text: 'Eggs' },
    { id: uuid(), text: 'Bread' },
    { id: uuid(), text: 'Juice' }
]);
Run Code Online (Sandbox Code Playgroud)

我已将其导入为import { uuid } from 'uuidv4';

有什么帮助吗?

node-modules reactjs react-native node-uuid

1
推荐指数
2
解决办法
6872
查看次数

选择一个组件时选择和取消选择组件

我必须显示三个组件(卡),用户可以从中选择一个。我将这三个组件放置在 a 中ScrollView

...
            <ScrollView horizontal={true} showsHorizontalScrollIndicator={false}>
                <LocationAndPriceCard
                    price={'100'}
                    title={'Choice 3'} />
                <LocationAndPriceCard
                    price={'200'}
                    title={'Choice 2'} />
                <LocationAndPriceCard
                    price={'300'}
                    title={'Choice 1'}} />
            </ScrollView>
...
Run Code Online (Sandbox Code Playgroud)

以下是LocationAndPriceCard编码方式:

...
function LocationAndPriceCard({ price, title }) {

    const [selectedLocation, setSelectedLocation] = useState("red")

    const styles = getStyles(selectedLocation);

    const selected = () => {
        if (selectedLocation == "red") {
            setSelectedLocation("green")
        } else {
            setSelectedLocation("red")
        }
    }

    return (
        <TouchableOpacity style={styles.frame} onPress={selected}>

            <Text style={styles.priceTxt}>RM {price}</Text>
            <Text style={styles.title} numberOfLines={2}>{title}</Text>
        </TouchableOpacity>
    );
}

const getStyles = …
Run Code Online (Sandbox Code Playgroud)

react-native touchableopacity use-state

0
推荐指数
1
解决办法
3807
查看次数