小编El *_*bre的帖子

Laravel Auth ::用户关系

Laravel中,我试图显示Auth :: user用户)和Departments之间的关系元素。在用户表中,我具有idnamedepartment_id。在Departments表中,我具有idname

在用户模型中,我创建

public function department()
    {
        return $this->belongsTo('App\Models\Department');
    }
Run Code Online (Sandbox Code Playgroud)

然后,在刀片模板中尝试

Auth :: user()->部门

但是返回null,不显示链接的 部门。Null不正确,所有用户都有部门。o,有帮助吗?¿关系有什么问题?

laravel

5
推荐指数
3
解决办法
6778
查看次数

Flutter - 下拉菜单中的默认值

我正在尝试将一个元素发送到一个视图。此元素将是第二页下拉列表中的默认元素。我在第一页使用类似的东西

  onTap: () {
                        Navigator.push(
                            context,
                            new MaterialPageRoute(
                                builder: (context) => new SummaryPage(,
                                    dropdownItem: dropdownSelection)));
                      } 
Run Code Online (Sandbox Code Playgroud)

然后在第二页我创建未来以获取下拉列表中的所有元素和 initstate 方法来设置默认元素下拉列表

 List data = List();

 Future<Null> getEstates() async {
    final response = await http
        .get('URL'
    }).catchError((error) {
      print(error.toString());
    });
    final responseJson = json.decode(response.body);
    final getBody = responseJson['body'];
    setState(() {
      data = getBody;
      loading = false;
    });
  }


 void initState() {
    super.initState();     

     setState(() {
          dropdownSelection = widget.dropdownItem.toString();
        });
Run Code Online (Sandbox Code Playgroud)

getEstate 返回这个

[{id: 1, 描述: Terreno Rio}, {id: 2, 描述: Terreno Asier}]

下拉看起来类似于这个

child: ButtonTheme( …
Run Code Online (Sandbox Code Playgroud)

dart dropdown flutter

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

将动画滑动到底部

我在页面底部有一个点指示器。我需要在滑动到底部5秒钟后将其隐藏。当用户移至其他页面时,显示的点会滑到顶部,最后在5秒钟后再次隐藏。现在,点在淡出5秒后隐藏起来,但是我需要其他类型的动画。

import 'package:flutter/material.dart';
import 'package:iGota/screens/partials/dots_indicator.dart';
import 'package:iGota/screens/posts_page.dart';
import 'package:iGota/screens/maps_page.dart';

class HomePage extends StatefulWidget {
  static String tag = 'home-page';

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<HomePage> {
  final _controller = new PageController();
  static const _kDuration = const Duration(milliseconds: 300);
  static const _kCurve = Curves.ease;
  final _kArrowColor = Colors.black.withOpacity(0.8);
  bool _visible = true;

  void initState() {
    super.initState();
    Future.delayed(Duration(milliseconds: 5)).then((_) => _visible = !_visible);
  }

  @override
  Widget build(BuildContext context) {
    final List<Widget> _pages = <Widget>[
      new ConstrainedBox(
        constraints: const …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

Flutter - 点击检测 TexField

我在 Windows 中制作了一个 flutter 应用程序并且一切正常,但是当我尝试编译到 iOS 时抛出了一个意外错误。在文本字段中检测到“onTap”不是正确的参数。我不知道会发生什么,在 Windows 中不会返回此错误。反正。有人知道如何解决这个问题以及在 texfield 上检测“onTap”的正确方法是什么?

 new Container(
          color: Colors.blue[300],
          child: new Padding(
            padding: const EdgeInsets.all(8.0),
            child: new Card(
              child: new ListTile(
                leading: new Icon(Icons.search),
                title: new TextField(
                  onTap: () { <--- The named parameter 'onTap' isn´t defined
                    Navigator.push(
                        context,
Run Code Online (Sandbox Code Playgroud)

更新

我试过这个但不起作用

 title: new GestureDetector(
            child: new TextField(
          controller: searchController,
          decoration: new InputDecoration(
              hintText: 'Buscar parcela', border: InputBorder.none),
        )),
        onTap: () {
          Navigator.push(
              context,
              new MaterialPageRoute(
                  builder: (context) => new EstatesPage(
                      parcela: widget.parcela,
                      dropdownItem: dropdownSelection))); …
Run Code Online (Sandbox Code Playgroud)

dart flutter

4
推荐指数
3
解决办法
5248
查看次数

Vuetify - 设置背景 img

Vuetify中(Vue组件超级集)中,我想在背景中添加图像图案。

\n\n

我试过

\n\n
body {\n    background: url("/images/background.png") no-repeat center center fixed;\n    background-size: cover;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

但这不起作用,某些 vuetify 组件取消了这种样式。我想要一种优雅的方式来做到这一点,而不是直接在组件或 html 中插入样式。

\n\n

有人遇到过这个错误吗?我如何解决它?

\n

css vue.js vuetify.js

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

Flutter - 谷歌地图不会等待定位

我正在尝试显示当前位置的地图。为此,我使用了位置谷歌地图插件(最新版本)。

我有一个类似的代码:

var lng, lat;

          @override
          initState() {
            super.initState();
            loading = true;
            getLocation();
          }

              Future getLocation() async {
                    final location = Location();
                    var currentLocation = await location.getLocation();
                    setState(() {
                      lat = currentLocation.latitude;
                      lng = currentLocation.longitude;
                      loading=false;
                    });
                  }

             loading==false ? GoogleMap(
                 mapType: MapType.hybrid,
                 myLocationButtonEnabled: true,
                 myLocationEnabled: true,
                 initialCameraPosition: CameraPosition(
                      target: LatLng(lat, lng),
                      zoom: 15.0,
                            )):null,
Run Code Online (Sandbox Code Playgroud)

当我们使用地图查看视图时,会在 1 秒左右出现错误(然后正确加载视图),并在控制台中显示此错误

我/扑(15567):???小部件库捕获的异常 ????????????????????????????????????????????? ??????????????? I/flutter (15567): 以下断言被抛出构建 HomePageScreen(dirty, dependencies: I/flutter (15567): [_LocalizationsScope-[GlobalKey#78c30], MediaQuery], state: _HomePageScreen#9c9d2): I/flutter (15567) ): 'package:google_maps_flutter/src/location.dart': …

google-maps flutter

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

Flutter - 重启 CountdownTimer

我有一个倒数计时器(5 分钟)。我需要一些东西来重新开始这个倒计时并从头开始。

我尝试更改倒计时变量的状态但不起作用,停止并从计数器的最后一个数字重新启动。

我的代码:

import 'package:flutter/material.dart';
    import 'package:intl/intl.dart';
    import 'package:quiver/async.dart';

    class ProgressIndicatorDemo extends StatefulWidget {
      @override
      _ProgressIndicatorDemoState createState() =>
          new _ProgressIndicatorDemoState();
    }

    class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo>
        with SingleTickerProviderStateMixin {
      AnimationController controller;
      Animation<double> animation;
      var countdown;
      int actual;

      @override
      void initState() {
        super.initState();
        animationStart();
        startTimer();
      }

      @override
      void dispose() {
        controller.dispose();
        super.dispose();
      }

      void animationStart() {
        controller =
            AnimationController(duration: Duration(minutes: 5), vsync: this);
        animation = Tween(begin: 0.0, end: 1.0).animate(controller)
          ..addListener(() {
            setState(() {});
          });
        controller.forward();
      }

      void startTimer() {
        CountdownTimer countDownTimer …
Run Code Online (Sandbox Code Playgroud)

flutter

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

Angular 8 - 将 base64 解析为文件

我正在尝试使用此代码转换 base64 文件

  new File([new Blob([BASE64FILE], {type: 'image/png'})],NAME,  {type: 'image/png'})
Run Code Online (Sandbox Code Playgroud)

有什么不对劲。当我将它发送到数据库时,格式不正确(不是图像)并且不显示任何内容。

所以问题是:将 base64 转换为 File 的正确方法是什么?

angular

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

Docker - 无法更改 phpmyadmin 的默认密码

在 docker compose 文件中我有 phpmyadmin,像这样

 phpmyadmin:
        image: phpmyadmin/phpmyadmin
        hostname: 'phpmyadmin'
        container_name: 'phpmyadmin'
        links:
          - database:db
        environment:
            MYSQL_USER: root
            MYSQL_PASSWORD: secret
            MYSQL_ROOT_PASSWORD: secret
        ports:
          - 8000:80
Run Code Online (Sandbox Code Playgroud)

当我使用此密码和用户尝试登录 phpmyadmin 时,返回未授权。那么,如何更改 phpmyadmin docker 的默认用户和密码?

docker

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

角度-比较字符串

问题很简单:

我需要将当前用户与用户列表进行比较

<tr *ngFor="let user of users">
     <td>
     <a *ngIf="'user.usuario' != usuario" title="{{'delete' | translate}}" 
          (click)="delete(user)"><i class="fas fa-trash"></i></a> 
     </td>
</tr>
Run Code Online (Sandbox Code Playgroud)

当前用户是usuariouser.usuario是循环中的用户。当user.usuario!= usuario我需要显示此元素时,当user.usuario == usuario我需要隐藏它。

问题:这种情况不起作用。怎么了?{{usuario}}返回值。

更新

用户数组

0: {idUsuario: 20, usuario: "iotadmin", nombre: null, apellidos: null, …}
1: {idUsuario: 21, usuario: "xiborra", nombre: "Xavi", apellidos: "Iborra", …}
2: {idUsuario: 22, usuario: "sergio", nombre: "Sergio", apellidos: "Hernando", …}
3: {idUsuario: 23, usuario: "alara", nombre: "Asier", apellidos: "Lara", …}
4: {idUsuario: 25, …
Run Code Online (Sandbox Code Playgroud)

angular

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

标签 统计

flutter ×5

dart ×3

angular ×2

css ×1

docker ×1

dropdown ×1

google-maps ×1

laravel ×1

vue.js ×1

vuetify.js ×1